RE:Re: Adding Your Own Classes to ROOT

From: Masaharu Goto (MXJ02154@nifty.ne.jp)
Date: Mon Jan 18 1999 - 12:31:19 MET


Simon and Rene,

I think the problem is missing static member body declaration. You need to add
following declaration outside of Geometry class definition.

    int Geometry::m_pixel_b_layer[26];
    int Geometry::m_pixel_barrel_1[26];
    int Geometry::m_pixel_barrel_2[22];
    int Geometry::m_sct_barrel_1[24];
    int Geometry::m_sct_barrel_2[24];
    int Geometry::m_sct_barrel_3[24];
    int Geometry::m_sct_barrel_4[24];
    int Geometry::m_pixel_disk_1[8];
    int Geometry::m_pixel_disk_2[8];
    int Geometry::m_pixel_disk_3[8];
    int Geometry::m_pixel_disk_4[4];
    int Geometry::m_sct_disk_1[24];
    int Geometry::m_sct_disk_2[16];
    int Geometry::m_sct_disk_3[24];
    int Geometry::m_sct_disk_4[24];
    int Geometry::m_sct_disk_5[24];
    int Geometry::m_sct_disk_6[24];
    int Geometry::m_sct_disk_7[16];
    int Geometry::m_sct_disk_8[16];
    int Geometry::m_sct_disk_9[8];

Please read C++ documentation about static data member declaration. You 
need both definition and declaration. Making the static member non-public
masks the problem because linker does not check existence of the member,
but it will cause problem anyway. 

  class A {
   public:
    static int a; // declaration
  };

  int A::a = 123; // definition

Masaharu Goto

>Hi Simon,
>To get your class working, move the definition of static members
>from the public to private or protected area.
>The problem has been reported to Masa.
>
>Rene Brun
>
>S.J.M. Peeters wrote:
> 
> Hi ROOTers,
> 
> I would like CINT to recognize my class, but it will not, whatever I do.
> I followed the example, used the standard MyClass as stated there and that
> works. When I use my class (Geometry) it will not recognize it:
> 
> root [0] Geometry a;
> Error: No symbol Geometrya in current scope  FILE:/var/tmp/aaaa18497
> LINE:1
> *** Interpreter error recovered ***
> 
> I suspect the problems is in the statics I use, but I'm not sure.
> Is this the problem? If so, what can I do about it?
> If not so, can anybody see the problem?
> 
> This is the header file:
> (the statics are at the bottom)
> 
> #ifndef __GEOMETRY_H__
> #define __GEOMETRY_H__
> 
> #include "config.h"
> #include "TMath.h"
> 
> class Geometry
> {
> private:
> 
>    int m_dice1;
>    int m_dice2;
>    int m_dice3;
> 
> public:
> 
>    Geometry(int dice1, int dice2, int dice3);
>    Geometry();
> 
>    // set member variables
>    void set_dice1(int dice1);
>    void set_dice2(int dice2);
>    void set_dice3(int dice3);
> 
>    // return ring number
>    // 1 - x
>    // Count from IP to outside
>    int pixel_barrel_ring(void);
>    int pixel_disk_ring(void);
>    int sct_barrel_ring(void);
>    int sct_disk_ring(void);
>    int ring(void);
> 
>    // return subring: 0 or 1
>    int sct_disk_subring(void);
>    int subring(void);
> 
>    // return sign z axes of module position
>    // pixelbarrel has 0
>    int pixel_disk_z_sign(void);
>    int sct_disk_z_sign(void);
>    int z_sign(void);
> 
>    // if (tilt) the module is tilted
>    int tilt(void);
> 
>    // return r of z coordinate
>    float r_ring(void);
>    float z_ring(void);
> 
>    // return eta at (r,z)
>    float eta(float r, float z);
> 
>    // return pseudo rapidity range of module
>    float D_eta(void);
> 
>    // return number of subdetectors in subsystem (for looping)
>    int number_of_detectors(void);
>    int number_of_subdetectors(void);
>    int number_of_rings(void);
> 
>    // return code as function of counter (for looping)
>    int dice1_code(int cntr);
>    int dice2_code(int cntr);
>    int dice3_code(int cntr);
> 
>    static int m_pixel_b_layer[26];
>    static int m_pixel_barrel_1[26];
>    static int m_pixel_barrel_2[22];
>    static int m_sct_barrel_1[24];
>    static int m_sct_barrel_2[24];
>    static int m_sct_barrel_3[24];
>    static int m_sct_barrel_4[24];
>    static int m_pixel_disk_1[8];
>    static int m_pixel_disk_2[8];
>    static int m_pixel_disk_3[8];
>    static int m_pixel_disk_4[4];
>    static int m_sct_disk_1[24];
>    static int m_sct_disk_2[16];
>    static int m_sct_disk_3[24];
>    static int m_sct_disk_4[24];
>    static int m_sct_disk_5[24];
>    static int m_sct_disk_6[24];
>    static int m_sct_disk_7[16];
>    static int m_sct_disk_8[16];
>    static int m_sct_disk_9[8];
> 
> };
> #endif
> 
> --
>     NIKHEF, National Institute for Nuclear and High Energy Physics
>     Kruislaan 409, office H-044 Tel:(+31-20-592) 5140
>     P.O. Box 41882, 1009 DB Amsterdam (NL) Fax:(+31-20-592) 5155
>     CERN, building 40, office 2-D06 Tel:(+41-22-76) 71157



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