Adding nested class to Root

Imagine I have

#include <iostream.h>
#include "TObject.h"
class SClass : public TObject {
   private:
      Float_t   fX;         //x position in centimeters
      Float_t   fY;         //y position in centimeters
   public:
      class CN:public TObject
{
CN();
ClassDef(CN)
}
      SClass()             { fX = fY = -1; }
      void Print() const;
 
ClassDef(SClass, 1)
};

How do I properly write a ClassDef and ClassImp statements for a nestedclass CN?
What pragma statement do I need to add to a LinkDef file?

Hi,

very pragmatically :slight_smile: :

> cat a.h 
#include <TObject.h>

class A {
public:
   class B {
      ClassDef(B, 1)
   };

   ClassDef(A, 1)
};

> cat linkdef.h 
#ifdef __CLING__

#pragma link C++ class A::B;

#endif

Invocation:

rootcling -f a_dict.cpp a.h linkdef.h

Cheers,
Danilo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.