footloose
asked on
CTypedPointerList...
I have class declarations like this:
class SomeClass
{
//blah blah
};
class SomeOtherClass
{
protected:
CTypedPtrList<CPtrList, CSomeClass*> m_Fields;
};
I want to add a member function getFields() that returns a reference to the m_Fields member variable. How should the the function be declared ?
This is not a homework problem.
class SomeClass
{
//blah blah
};
class SomeOtherClass
{
protected:
CTypedPtrList<CPtrList, CSomeClass*> m_Fields;
};
I want to add a member function getFields() that returns a reference to the m_Fields member variable. How should the the function be declared ?
This is not a homework problem.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, guys. I will follow RONSLOW's model.
eg:
class SomeClass
{
//blah blah
};
typedef CTypedPtrList<CPtrList, CSomeClass*> CSomeClassList;
class SomeOtherClass
{
protected:
CSomeClassList m_Fields;
public:
CSomeCLassList& getFields() { return m_Fields; }
const CSomeCLassList& getFields() const { return m_Fields; }
};
NOTE: I also included a const function .. its often a good idea with access functions. In fact, sometimes you ONLY want the const version.