[Insight-users] Inheritance problem with SmartPointer

Lemeur Yann Yann.Lemeur at stage.cnes.fr
Tue, 27 Apr 2004 11:14:28 +0200


Hi everybody,
Here is my problem: I have a class B which inherit from class A. In this class A there is a public method called 
virtual void SetToUnion(A::Pointer x, A::Pointer y) 
where Pointer is defined like this: typedef SmartPointer<A> Pointer.

I don't redefine the SetToUnion method in class B.
In class B there is another typedef : typedef SmartPointer<B> Pointer;
I've made a test program for class B where I call SetToUnion like this:


B::Pointer x = B::New();
B::Pointer y = B::New();
......
.....
B::Pointer z = B::New();
z->SetToUnion(x,y);       <--------------------- Daesn't compile!

There is an error at compilation which tells me something like this : 

"No matching fonction for call to B::SetToUnion(B::Pointer, B::Pointer). Candidates are A::SetToUnion(A::Pointer,A::Pointer)"

I'm sure there is no error in the test program. To my mind, the compiler crashes because it daesn't understand that B::Pointer is also a A::Pointer (by inheritance)...
Daes somebedy know a solution?
Thanks a lot!

Yann