•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 363,805 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,660 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 143 | Replies: 3
•
•
Join Date: Dec 2007
Posts: 173
Reputation:
Rep Power: 1
Solved Threads: 1
I'm having a little problem with a conversion error during compile. Here is the code:
Now in the last line it gives me the error cannot convert 'this' pointer from const costOfItem to costOfItem conversion loses qualifiers. I'm assuming there is a problem with the current instance of the object (which I believe is what 'this' points to, please correct me if I'm wrong about that) and it seems to be trying to convert it to a non const. What seems to be the problem and how do I fix it?
#include <iostream>
using namespace std;
class costOfItem
{
public:
costOfItem(float i_cost);
void printMe();
private:
const float price;
};
// Free functions
void displayPrice(costOfItem z) { z.printMe(); }
void displayRefPrice(costOfItem &z) { z.printMe(); }
void displayConstRef(const costOfItem &z) { z.printMe(); } •
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
Similar Threads
- memory management in wndows 2000 (Windows NT / 2000 / XP / 2003)
- Overloaded + operator not working correctly. (C++)
- c++ compilation error (C++)
- C++ const help (C++)
- FILE + conversion from dec to hex = I need help (C)
- help with conversion calculator (C)
- file input don't know where to start (C++)
- help needed with errors (C++)
- plzzz help! i did the work need (C)
Other Threads in the C++ Forum
- Previous Thread: C++ Bubble sort not working with array of records, does work with simple array.
- Next Thread: test



Threaded Mode