R
Richard
I'm using Eclipse with the new C/C++ plugin and the MSYS compiler to
complete my assignments for programming class. The program I have now
is almost complete, however, it is generating a syntax error when I
try to call the readFraction method on my Fraction object.
I've been over it again and again and I don't see what's wrong here. I
tried modifying readFraction to accept no arguments, and changed the
method calls to not pass any arguments. No dice. Same error!!
The syntax error is generated in main() on the f1.readFraction() and
f2.readFraction() method calls. The error I'm getting is "request for
member `readFraction' in `f1()', which is of", whatever the heck that
means.
It seems like this should work. Any help would be appreciated! Please
post here and don't e-mail as I don't check my Hotmail that often.
CODE BELOW -------------------------
#include <iostream>
class Fraction {
int numerator, denominator;
public:
Fraction(int whole) {
this->numerator = whole;
this->denominator = 1;
}
Fraction(int numerator, int denominator) {
this->numerator = numerator;
this->denominator = denominator;
}
void readFraction(char* prompt) {
char* sfrac;
std::cout << prompt << "\n";
std::cin >> sfrac;
}
};
int main() {
Fraction f1(), f2(), f3();
f1.readFraction("Enter 1st fraction:");
f2.readFraction("Enter 2nd fraction:");
}
complete my assignments for programming class. The program I have now
is almost complete, however, it is generating a syntax error when I
try to call the readFraction method on my Fraction object.
I've been over it again and again and I don't see what's wrong here. I
tried modifying readFraction to accept no arguments, and changed the
method calls to not pass any arguments. No dice. Same error!!
The syntax error is generated in main() on the f1.readFraction() and
f2.readFraction() method calls. The error I'm getting is "request for
member `readFraction' in `f1()', which is of", whatever the heck that
means.
It seems like this should work. Any help would be appreciated! Please
post here and don't e-mail as I don't check my Hotmail that often.
CODE BELOW -------------------------
#include <iostream>
class Fraction {
int numerator, denominator;
public:
Fraction(int whole) {
this->numerator = whole;
this->denominator = 1;
}
Fraction(int numerator, int denominator) {
this->numerator = numerator;
this->denominator = denominator;
}
void readFraction(char* prompt) {
char* sfrac;
std::cout << prompt << "\n";
std::cin >> sfrac;
}
};
int main() {
Fraction f1(), f2(), f3();
f1.readFraction("Enter 1st fraction:");
f2.readFraction("Enter 2nd fraction:");
}