0

Is it possible to overload an operator for a built-in type? And if so what is it's syntax?
EG:

//Use of overloaded operator^ for types double and double (assuming it is overloaded for exponent):
double a=10.0;
double b=2.5;
double pow=a^b;//pow is approximately 316.22....
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by L7Sqr
0

No.
In order to do what you want you need to 'wrap' the type in a class and provide operators through that interface.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.