nil_dib
asked on
MyMethod()const ..question
suppose I have two classes with a const method in the
derived class:
class A
{
int m_nX;
};
class B : public A
{
int m_nY;
int GetValue() const
{ return m_nY; }
};
in this case everthing is allright.
the question: is it legal/proper to do something like
class B : public A
{
int m_nY;
int GetValue() const
{
m_nX = 4;
return m_nY;
}
};
concerning the const method "GetValue()" ???
derived class:
class A
{
int m_nX;
};
class B : public A
{
int m_nY;
int GetValue() const
{ return m_nY; }
};
in this case everthing is allright.
the question: is it legal/proper to do something like
class B : public A
{
int m_nY;
int GetValue() const
{
m_nX = 4;
return m_nY;
}
};
concerning the const method "GetValue()" ???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Note also that m_nX is a private member of the base class. Thus the error you will get is that m_nX is undefined, not that it is constant. If it were made public or protected, then you would get the error that it is constant.