![]() |
|
#1
|
|||
|
|||
Operator overloading c++I am trying to make a program that makes a complex number class that will add subtract multiply and divide complex numbers. I am trying to make my code easier by using operator overloading but am running into some errors that I am stuck on. If anyone can help please do.
CPP / C++ / C Code:
CPP / C++ / C Code:
Thats the header and the cpp files Last edited by LuciWiz : 24-Apr-2005 at 13:59.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#2
|
|||
|
|||
|
CPP / C++ / C Code:
I am getting several errors with this part of the code It says it cannt acces the private members, even though I used "friend" Last edited by LuciWiz : 24-Apr-2005 at 13:59.
Reason: Please insert your C++ code between [c++] & [/c++] tags
|
|
#3
|
|||
|
|||
|
Quote:
CPP / C++ / C Code:
here is a great reference on operator overloading: http://www.csse.monash.edu.au/~jonmc...html/text.html other references can easily be found using google. |
|
#4
|
|||
|
|||
|
I am also getting other errors with my use of the << and >> operators
It says that there is no operator found which takes a right hand operand of type Complex I did also put in the Complex:: and it gave me errors for that when I took them out the errors went away which I thought was unusual but I looked in a book and they didn't have it in there either. |
|
#5
|
|||
|
|||
|
Also when I tried to do what you showed as an example it says that there is an error with the arrow and this it says left of ->imag must point to class/struct/union and the same with ->real
also it give me a error saying hat Complex::imag cannot access private member declared in class complex |
Recent GIDBlog
Meeting the local Iraqis by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The