| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Overloading Error
In a program I am writing I need to overload the addition operator to take a integer value and add it to a rational value. But when I try to compile it I get this error message: "must take either zero or one argument". Does anyone know what this means?? I've tried to make it a friend but when I do that it tells me that the prototype for that function does not match any in the class. So is there anything I can do???
|
|
#2
|
|||
|
|||
|
It hard to know exactly what that means without looking at the code, but I think your missing a parameter in your overloaded operator. Your declaration should look like this but with Type replaced by the name of your class: Type operator+( Type& rhv );
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Overloading Error |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|