If you want to integrate your classes into the ROOT system, to enjoy features like, extensive RTTI and ROOT object I/O, you have to add the following line to your class header files (as part of the public part of the class definition):
ClassDef(ClassName,ClassVersionID) //The class titleSee for example TLine.h. The ClassVersionID is used by the ROOT I/O system. It is written on the output stream and during reading you can check this version ID and take appropriate action depending on the value of the ID (see Streamer). Every time you change the layout of a class you should increase its ClassVersionID by one. The ClassVersionID should be greater or equal to 1. Set ClassVersionID=0 in case you don't need object I/O.
NOTE: the ClassDef macro must be the last item before the closing '};' in a class definition. It contains its own private and public tags so it can be added to either a private or public part of a class definition.
Similarly, in your implementation file you must add the statement:
ClassImp(ClassName)See for example TLine.cxx. Note that you MUST provide a default constructor for your classes, i.e. a constructor with zero parameters or with one or more parameters all with default values in case you want to use object I/O. If not you will get a compile time error.
The ClassDef and ClassImp macros are defined in the file Rtypes.h. This file is referenced by all ROOT include files, so you will automatically get them if you use a ROOT include file.
The ClassDef and ClassImp macros are necessary to link your classes to the dictionary generated by CINT to get access to the RTTI and object I/O features of ROOT. The RTTI system allows you to, a.o. find out to which class an object belongs, its baseclasses, its datamembers and methods, the method signatures, etc. This information is used to make advanced object browsers and by the automatic documentation generation system. The object I/O system allows you to store and retrieve objects (and arbitrarily complex object structures) from a ROOT database.
If you are only interested in interactive access to your classes via the command line or macro processor you do not need to use the ClassDef and ClassImp macros.
See "CINT as Dictionary
Generator" for a description on how to generate a dictionary.