How does root implement square operator a**2 in C++ frame?

I know in Root we can use a2.0 to calculate the square of number a. But I don’t know how does this ** operator implemented. I learned from all C++ books and internet C++ tutorials that in C++ you can’t define new operators like square ab or power a^b, because the compiler will treat them as " a times (*b) where b is a point" and " a xor b". I really want to know this technique, do any one know the answer?

I tried to use a macro “#define a**2 (a)*(a)” in C++, of cause this failed. Is there a smart macro in Root or a complicated modification on the compiler?

Thank your guys very much for any help.

This works only in CINT and it is a convenient form when typing at the command line or when defining mathematical functions in TF1,2 for example.
You should not use this extension in compiled code or in script that you want to run with ACLIC.

Rene

It seems impossible to define the square operator a**2 in C++, which is quite different from Fortran where ** is a intrinsic operator. Thank you very much.