Original Post
Hi all,
ex:
class someClass
{
public:
...
type* getVar();
...
private:
type privateTypeVar;
}
somewhere in main loop
someClass classInstance;
type* pType = classInstance->getVar();
*pType = somevalue;
wondering what''s the implication of this
is it a good idea to create a accessor function that returns a pointer to a private member if i want access to that private member. I thoguth this was illegal but it seems to compile and work? If the object instance gets destroyed, then the pointer will point to mess right?
If this is not a good technique, then what is a better technique in doin''g something like this (reducde copy constructing)