I have a class:
class Object
{
public:
LPTSTR getName();
private:
LPTSTR lpstr_ObjectName;
};
LPTSTR Object::getName()
{
return lpstr_ObjectName;
}
I have another class:
class SomeOtherClass : Object
{
public:
void doSomethingCool();
};
void SomeOtherClass::doSomethingCool()
{
if(getName() == <oneThing>)
//do something cool
else
//do something else cool
}
Now, this all looks good and everything. That is, until I compile it and get a scope error saying
<SomeOtherClass> isn't allowed to reference private/protected member <getName()> from class <Object>.
I'm not quite sure what to make of this, as the getName() function was explicitly defined as being public. I'm guessing I missed something in the "fine print" section of the C++ Manual here because it at least LOOKS like it should work.
Any suggestions?
class Object
{
public:
LPTSTR getName();
private:
LPTSTR lpstr_ObjectName;
};
LPTSTR Object::getName()
{
return lpstr_ObjectName;
}
I have another class:
class SomeOtherClass : Object
{
public:
void doSomethingCool();
};
void SomeOtherClass::doSomethingCool()
{
if(getName() == <oneThing>)
//do something cool
else
//do something else cool
}
Now, this all looks good and everything. That is, until I compile it and get a scope error saying
<SomeOtherClass> isn't allowed to reference private/protected member <getName()> from class <Object>.
I'm not quite sure what to make of this, as the getName() function was explicitly defined as being public. I'm guessing I missed something in the "fine print" section of the C++ Manual here because it at least LOOKS like it should work.
Any suggestions?