Reputation: 580
The class with this code is a reference class for a pointer of ClassName, i.e.:
class ClassName;
class ClassRef
{
ClassName* m_class;
...
operator ClassName *() const { return m_class; }
...
I am assuming this is used for pointer validity checks, such as:
ClassRef ref(new ClassName())
if (ref) { bla bla bla }
Am I correct in my thinking?
Upvotes: 5
Views: 2057
Reputation: 4698
This is an overload of the conversion operator. Whenever a ClassRef
object needs to be converted to a ClassName
pointer type, this operator is called.
So;
ClassRef r;
ClassName * p = r;
will make use of this overload.
Upvotes: 10