Can I change of default output of a class in ROOT prompt?


_ROOT Version:6.28.06


Hi all:
Can I change of the default output of a class.
the default like below

cx[000]:> struct {double a; double b;} c;
cx[001]:> c
(struct (unnamed) &) @0x1373c8000

I’d like to change it like below

cx[000]:> struct {double a; double b;} c;
cx[001]:> c
{0.0, 0.0}

I try to write the operator<< but it didn’t work.

1 Like

Maybe @axel can help you on this/

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

Sorry for the super slow response. Try this:

root [0] .rawInput
Using raw input
root [1] struct S {double a; double b;}; namespace cling { std::string printValue(S* s) { return std::to_string(s->a+s->b) + " is my sum"; } }
root [2] .rawInput
Not using raw input
root [3] S s{17., 42.}
(S &) 59.000000 is my sum

(the .rawInput is needed to allow the struct and namespace to end up on global scope; it won’t be needed in a script.)

2 Likes

This topic was automatically closed after 9 days. New replies are no longer allowed.