"return function" doesn't work
here's my simplified codes:
Code:
class Drug
{
public:
Drug(): avai(0) {};
bool& get_avai()
{
return avai;
}
protected:
bool avai;
};
if (somedrug.get_avai())
{
//do something
}
my compiler (Dev-C++) says " cannot convert Drug::get_avai()' to `
how come?:confused:
I am not sure about this.
I tried to compile your class with an empty main and the only line that gave me problems was
Code:
Drug(): avai(0) {};
there is a colon after the function Drug. I think that is supposed to be a constructor? If it is there is no colon after it just braces with whatever constructor code. The next part with the avai function gives me a syntax error for a constant? Not sure if that helps or not. If I take out the line above it compiles with no errors. I don't see where you have any destructors?
Code:
Drug(paramater list here for constructor)
{ constructor code here }
~Drug()
{ destructor code here or empty if no clean up needed }