Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
C++ Problem
Name: Den Date: September 19, 2002 at 16:49:30 Pacific OS: Win2k CPU/Ram: p4
Comment:
I got this error every time I compiler operator-(): "error C2804: binary 'operator +' has too many parameters"
class Fraction { public: Fraction () { num = 0; deno = 0, result = 0;}; Fraction(int x, int y) { num = x, deno = y;}; Fraction operator +(Fraction& x, Fraction& y); //this line generates the above erro void menu(); double num, deno, result; };
Name: Jeff J Date: September 19, 2002 at 18:10:33 Pacific
Reply:
Your overload of the + operator would be perfectly fine if it was defined outside the class (as that requires two parameters). Within a class definition, the left-hand-side operand is already assumed to be 'this', so only the right-hand-side operand can be specified as a singular parameter.
You can either move the function outside the class, or remove one of the parameters in the member function.
Summary: I'm taking a C++ class, and I have a problem I can't seem to figure out, I'm taking all the information from one file and transferring it to another. The content of the files looks something like this...
Summary: I have a problem when executing pieces of code of this type: main(){ char a,b; a=getchar(); b=getchar(); } The program waits for the first assignation and after the first character is stored,it exits ...
Summary: this problem is usual in C++ , it's very easy to compile but it's more difficult to execute. Analyse your code and find the probleme (maybe bad reference or pointer) ...