I'm having a little problem with a conversion error during compile. Here is the code:
#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(); }
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?