I have a quick question for an upcoming final. Are private member data and functions only accessible by the constructor?
Answer and elaboration appreciated.
Here’s the question and answer that prompted me to come to you guys:
EDIT:
5) Be able to determine when a statement is an invalid attempt to access private member variables or functions.
– This is a give away, private functions and variables can only be accessed in the constructor.
So this is wrong?
Yes, it’s plain wrong.
From the standard (ISO/IEC 14882:2003 (E), §11.0/1):
It says members, not constructor.