After I messed up the description of my previous post on this I have sat down and tried to convey my exact intent.
I have a class called P which performs some distinct purpose. I also have PW which perform some distinct purpose on P. PW has no member variables, just member functions.
From this description you would assume that the code would follow like this:
class P
{
public:
void a( );
};
class PW
{
public:
PW( const P& p ) : p( p ) { }
void b( );
P& p;
};
class C
{
public:
P GetP( ) const { return p; }
private:
P p;
};
// ...
PW& p = c.GetP( ); // valid
// ...
However that brings up a problem. I can't call the functions of P without indirection everywhere.
// ...
p->p->a( )
// ...
What I would like to do is call p->a( ) and have it automatically determine that I would like to call the member function of P.
Also having a member of PW called a doesn't really scale - what if I add (or remove) another function to P - this will need to be added (or removed) to PW.