Well, I'm not sure about this one.
I have a class like
class Object
{
int internalValue ;
struct SomeStructType
{
int superInternalValue ;
} someStruct ;
public:
int getInternalValue()
{
return internalValue ;
}
int getSuperInternalValue()
{
return someStruct.superInternalValue ;
}
void printThatInternalValue()
{
// Its seems pretty clear we should just access
// the private value directly and not use the public getter
printf( "%d", internalValue ) ;
}
void printThatSuperInternalValue()
{
// Now here the access pattern is getting more complicated.
// Shouldn't we just call the public access function
// getSuperInternalValue() instead, even though we are inside the class?
printf( "%d", someStruct.superInternalValue ) ;
}
} ;
So for the class's INTERNAL operations, it CAN use someStruct.superInternalValue directly, but it seems cleaner to use the class's public getter function getSuperInternalValue() instead.
The only drawback I can see is if you tried to modify superInternalValue using the getter would give you a copy, which is clearly not what you want in that case. But for reading access, should the public getter function be used internally inside a class?