Original Post
Let's say you have a base class Cat, and an inherited class Tiger. The virtual function for use is Meow().
This is perfectly fine:
Cat *pCat; Tiger *pTiger = new Tiger; pCat = pTiger; pCat->Meow(); //uses tiger's meowBut this is not:
Cat **ppCat; Tiger **ppTiger = new Tiger*[MAX_TIGERS]; //(then allocate for each ptr...) ppCat = ppTiger; //COMPILE ERROR! (*ppCat)->Meow();Anybody know why? HOWEVER... if replace the line in error with this:
ppCat = reinterpret_cast < Cat** > (ppTiger); (*ppCat)->Meow();...the meow called will be tiger's meow. Edit: source-ified [edited by - Scint on April 16, 2004 1:43:34 AM]