Re: Pointer to own class object

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Feb 26 1998 - 12:16:52 MET


Krieg, M. wrote:
> 
> Hi Roots!
> 
> I couldn't find a solution of the following problem in the complete ROOT Web
> page (including the RootTalk Digest) so I imagine it could be of general
> interest:
> 
> I have successfully included some own classes into the ROOT-System. The code
> compiled and worked well until I added to my code a constructor, that uses a
> pointer to a classobject of one of my own classes, lets say 'TOwnClass':
> 
> TAnotherOwnClass :: TAnotherOwnClass (TOwnClass*  ptr){...}
> 
> Something seems to be wrong with the dictionary file created by rootcint,
> since I get the following error message of the compiler:
> 
> mydict..cpp: no match for 'operator <<(class TBuffer, class TOwnClass*)'
> 
> here is a simplified version TOwnClass.h:
> 
> #include<iostream.h>
> #include"TGraph.h"
> class TOwnClass{
> private:
>      int TestVar;
> public:
>      TOwnClass();
>      ~TOwnClass();
>      void AnyFunction();
> };
> 
> my LinkDef.h contains the following lines:
> 
> #pragma link C++ class TOwnClass!;
> #pragma link C++ class AnotherOwnClass!;
> 
> (leaving out the exclamation mark at the end of the line or adding a minus,
> as well as any combination of both signs didn't change the error message)
> 
> What am I doing wrong? Do I have to add any function or operators to the
> class definitions? Do I have to inherit TOwnClass of TObject or any other
> ROOT class? (I tried that, but without success)?
> I hope I gave you all the  necessary information, thanks a lot in advance!
> 
> Martina
> (working with linux and GNU-Compiler)
> martina.krieg@etec.uni-karlsruhe.de


Martina,
You simply forgot to add the ClassDef statement in your header file
and ClassImp in your implementation file.
For a discussion on these two macros, see URL:
 http://root.cern.ch/root/CintGenerator.html
Also have a look at teh example in $ROOTSYS/test/Event

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET