Question

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

Was it helpful?

Solution

Just keep expanding out the tree in the Autos window or one of the Watch windows:

alt text http://www.freeimagehosting.net/uploads/626b4a37ee.png

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top