TTree::Branch question

Hello.
I am trying to make my own class and store objects of it on a tree.
My class looks like this:

Point.cpp:

#include <TObject.h>

class Point : public TObject
{
private:
  float x;
  float y;
  float z;

public:
  Point(float x, float y, float z);
  
  void SetPoint(float x, float y, float z);
  
  float GetPointX(void);
  float GetPointY(void);
  float GetPointZ(void);


  ClassDef(Point, 1);
};

Point::Point(float x, float y, float z)
{ this->x = x; this->y = y; this->z = z; }

void Point::SetPoint(float x, float y, float z)
{ this->x = x; this->y = y; this->z = z; }

float Point::GetPointX(void)
{ return this->x; }

float Point::GetPointY(void)
{ return this->y; }

float Point::GetPointZ(void)
{ return this->z; }

#if !defined(_CINT_)
ClassImp(Point);
#endif

.

My program is the following.
treestuff.cpp:

#include <stdio.h>
#include <TFile.h>
#include <TTree.h>
#include <TObject.h>
#include "Point.cpp"


int go(void)
{
  if (!TClass::GetDict("Point"))
    gROOT->ProcessLine(".L Point.cpp+");

  TFile *file = new TFile("foo.root","RECREATE","practice file");
  TTree *tree = new TTree("tree1","A glorious tree");

  Point *pnt = new Point(0,0,0);
  
  tree->Branch("PointBranch","Point",&pnt);
  
  return 0;
}

When I literally type what is in my program directly into the interpreter, everything seems to work fine, but when I try to do it by loading treestuff.cpp, I get the following output.

root [0] .L treestuff.cpp
root [1] go()
Error in <TTree::Branch>: The actual class (TObject) of the object provided for the definition of the branch "PointBranch" does not inherit from Point
(int)0

I don’t know what to make of this error. My object *pnt seems to be of class Point, not just TObject…

in your version of treestuff.cpp, you include Point.cpp before loading the compiled code, so CINT will create its own interpreted class and you will get a mismatch between the two. The solution is to do

root > .L Point.cpp+ root > .L treestuff.C or .L treestuff.C+ root > go()
with treetuff.C without the gROOT->ProcessLine statement

Rene

Thank you very much for the help. Everything seems to work now, but there is some output that I don’t understand when I compile:

root [1] .L treestuff.C+
Info in <TUnixSystem::ACLiC>: creating shared library /root/playground/./treestuff_C.so
Error in <TUnixSystem::DynamicPathName>: libvectorDict[.so | .sl | .dl | .a | .dll] does not exist in .:/root/software/root/lib::/root/software/root/lib:/root/software/root/lib:/root/software/root/lib:/root/software/root/cint/cint/stl

Is this something I should be concerned about?
Thanks!

Nothing to worry to run this simple example, but you may have a problem if you use std::vector.
I would need more info about your installation.

Ree