I found it is not ok to write the following code class1 is belong to class2, I want to transfer the input of class2 to class1 class1->SetInput(class2->GetInput()) while it is ok if I write: classinputtype::pointer c1input(class2->GetInput()); class1->SetInput(c1Input); anyone can explain this to me? Thanks! ting