I want to write a simple wrapper around another class. A small example:
class MyClass {
...
int someMember();
...
};
class MyClassRefernence{
...
MyClass* ptr;
MyClass& operator *();
...
};
If I have now some code like the following:
MyClassReference ref;
... // Init the ref and the pointer ptr.
int a = (*ref).someMember(); // this works but is nasty
int b = ref->someMember(); // Compile error
So my question is: Is there a way to use the much more pretty -> operator instead of the (*...). construction?
1 Answer