Cint var printing simple question


TString a(“a”)
Float_t x=1

root [6] a
(class TString)"a"
root [7] x

now if I create a class, how can I setup to cint display some member i want from that class, when just typing the name of the instance?



this is only implemented for simple types. You would have to call a function of your class, e.g. myObject.Print() returnign a const char*.

Cheers, Axel.

If you would like you object to be printed by the CINT command line, you simply need to have a function with the signature:int G__ateval(const MyClass &x);that call the proper printing routines.
This function can be either interpreted or compiled (with a dictionary :slight_smile: ).


1 Like

Cool 8)


Hello, it appears that this functionality has disappeared from ROOT6? Is there a new way to print the ‘value’ of an object in Clang? Apologies in advance for my ignorance–I’ve been out of it for a while.
–thanks, Chris

Int_t G__ateval(const TVector3& x) {
printf("(class TVector3) [ %f, %f, %f ]\n",x.x(),x.y(),x.z());

root [0] TVector3 v(1,2,3)
(TVector3 &) Name: TVector3 Title: A 3D physics vector

Looks like the printValue functions in the cling namespace now give this functionality

Thanks for the tip. I tried adding the following in my interpreted/compiled code, but it didn’t change the default behavior. Any thoughts? --thanks, Chris

std::string printValue (const TVector3 *v) {
return Form( “(class TVector3) [ %f, %f, %f ]\n”, v->x(), v->y(), v->z() );

Did you define it in the cling namespace? I’ve tried to define the printValue function in the interpreter for my custom empty class and it worked.

works like a charm! thanks :slight_smile:

namespace cling { std::string printValue( const TVector3 *v ) {
return Form( “(class TVector3) [ %f, %f, %f ]\n”, v->x(), v->y(), v->z() ); } }