Say you are given the following UML class diagram:

Can a variable of type Mystery invoke the function DoSomething()?
I understand that an object (say Mystery X;) could call GetA() to access the private variable int a
and to access the public variable int b all you need is X.b
but how could this object, X, access the private function DoSomething()
if it's even possible?
I had difficulty understanding exactly what you are asking, but I think I've figured it out.
If you are asking if, given the following declaration:
you can do something like this:
...then the answer is no. You cannot call
privatemember functions (or refer toprivatemember variables) from outside the context of the class. Only another member function ofMysterycan call theprivates. For example:EDIT:
Not only can you not call
privatemembers from outside the class, you also can't call them from subclasses. For example, this is not valid: