Why or when does somebody have a "pointer to a pointer of an instance"
instead of "an instance" or "a pointer to an instance"?
I think you should study some fundamental concepts about C related to
pointers.
VB6 or other environments hide the concept of pointers, but if you use
C/C++, you must have pointers knowledge.
The usual case of having "a pointer to a pointer of an instance" is when you
have a function or a method that returns a pointer to an instance as output
parameter.
e.g.
// Creates an instance of SomeClass class.
// The resulting instance is returned as 'ppSomeClassInstance' parameter.
// Returns true on success, false on error.
bool CreateSomeClassInstance(
SomeClass ** ppSomeClassInstance /* output parameter */
... some parameters ...
);
This use of double-pointer is done e.g. in COM IUnknown::QueryInterface (the
returned interface pointer is an output parameter for QueryInterface, so a
double-pointer is used).
You have a "pointer to an instance" when you don't want to pass instance "by
value" (forcing useless and expensive copy constructors and destructors
calls), but you want to pass "by pointer" or "by reference", I think that
this is similar to VB "ByRef" keyword (but I'm not a VB expert).
e.g.
class SomeClass;
void DoSomething( SomeClass x ); // x is an instance
void DoSomethingBetter( SomeClass * pX ); // pointer to instance of
SomeClass class
The second case just passes a pointer to the function, so there are no copy
constructor calls and no creation of temporary objects.
Passing by pointer is much more efficient especially if the class instance
is a big object, and has non-trivial copy semantics.
(Note that in C++ you can use references, that have a syntax similar to
passing by value, e.g. you can use operator dot instead of operator arrow,
but the semantics is similar to passing by pointer.)
....However, I think that you will have more details explanations about these
*important* C++ concepts if you spend some time reading some good book about
C++.
HTH,
Giovanni