All pastes #470315 Raw Edit

Untitled

public text v1 · immutable
·published 2007-05-04 05:53 UTC
rendered paste body
class Factory
{
   public:

        virtual void* getInterface(int IID)
        {
            Channel* res = 0;

            if(IID == IIDChan)
            {
                res = new Channel();
            }

            return res;
        }
}

// Code using the class:
Channel* chan = factory.getInterface(IIDChan);

// This crashes
chan->someMethod();

// But this doesn't:
Channel* chan = new Channel();
chan->someMethod();