Hello Axel,
thanks, but your suggestions do not work and is NOT what was my intention anyway !
> BaseB=(TClassA*)File->Get("ClassB");
> BaseB->Test(); (calls Test() of ClassB)
My compiler (MSVC 6.0) complains that it cannot convert ClassA to ClassB.
However this works correctly:
ClassA* Object=(ClassB*)File->Get("ClassB");
Object->test() calls ClassB->Test()
I want to describe further, why your suggestion does not solve the problem ! My app is similar to root browser, it reads the file and than calls a "Visualize" method on each object which than draws a table or graph depending on its class. So I DONT KNOW at compile time of which class the objects will be, I only know that all Objects inherit from TObject and ClassA and all have overwritten the virtual function visualize of ClassA.
So the desired behavior is like:
ClassA* Object;
if(key->GetClassName()==”ClassA”);
Object=(ClassA*)File->Get(key->GetName())
if(key->GetClassName()==”ClassB”);
Object=(ClassB*)File->Get(key->GetName())
But since I even don’t know which classes are on the file, that does not make any sense either.
I tried
ClassA* Object;
Object=(ClassA*)File->Get(“ClassB”);
This works but than crashes on calling Object->Test() with the error message:
The value of ESP was not properly saved across a function call. This is usually the result of calling functions declared with one calling convention with a function pointer declared with a different calling convention
So any clues ?
Joe>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET