Search This Blog

Tuesday, May 18, 2010

override the operator overloading in C++ ?

Programmer Question

helo guys



i have class call Complex



I did operator overloading like such



Complex c = a + b; // where a and b are object of Complex class 


which basically is operator+(Complex& that);



but I dont know how to say for example



double c = a + 10; //where a is object of Complex class but 10 is integer / double  


I did define typecasting for a to be double get my IDE says that there are too many operands + and it somehow complains for not being able to "understand" the +



it has to be in this format though double c = a + 10;



thanks



Find the answer here

No comments:

Post a Comment

Related Posts with Thumbnails