views:

168

answers:

2

I have a wrapper class that delegates its work to a pimpl, and the pimpl is a pointer to a baseclass/interface with no data that is specialized in several different ways.

Like this:

class Base
{
    void doStuff=0;
};

class Derived
{
    int x,y;
    void doStuff()
    {
     x = (x+y*2)*x; //whatever
    }
};

class Wrapper
{
    Base* _pimpl;
    void doStuff()
    {
     _pimpl->doStuff();
    }
};

Now this works fine most of the time, but when going into the debugger I can't view x,y of the Derived class (because it could be anything). Normally this is irrelevant, but when something goes wrong seeing the state of Derived can be important, but pimpl obscures the state too much (however that's the original idea of a pimpl, so I guess I can't really complain).

Now I have a tostring() function that prints the state out for debug purposes, but was wondering if there is a better solution, to debug this sort of construct in VisualStudio in particular, but a general solution would be better.

Thanks

+4  A: 

Have you tried casting the variable into Derived* in the watch window?

Assaf Lavie
yeah this works, good so far, but hopefully someone has a magical solution :)
Robert Gould
What would be more magical?
jmucchiello
+2  A: 
David Norman
Mmm, ok your right, but my actual code is more complex than this and it doesn't work right... let me figure out why it doesn't work...
Robert Gould
If you are doing it from a compilation unit that doesn't have visibility of the impl class declaration then it isn't visible
1800 INFORMATION
there we go! That's why it's not working
Robert Gould