Problem with argument list
I am trying to learn how to build a class and I am having trouble. My simple program reads in a fraction, and inverts it. I will do much more with it later if I can get past this problem. Currently I have two warnings, one about missing an argument list, and the other about using frac1 without it being initialized. I've banged my head on this for 2 days now, so I think it is time I ask for some help. Here is the code...
Code:
#include <iostream>
using namespace std;
char oper;
class SingleFraction
{
public:
void getFrac(SingleFraction ff1)
{
char misc;
cin >> num >> misc >> den >> oper;
}
void invert(SingleFraction ff1)
{
num = ff1.den;
den = ff1.num;
}
void display()
{
cout << num << '/' << den;
}
private:
int num, den;
};
int main()
{
SingleFraction frac1, fracAns;
char choice = 99;
while (choice != 'n' && choice != 'N')
{
cout << "Enter a fraction and operator: ";
frac1.getFrac; // warning here about missing argument list
switch(oper)
{
case 'i': fracAns.invert(frac1); break; // warning here about frac1 not being initialized
//default: cout << "Illegal operator.";
continue;
}
fracAns.display();
cout << "Answer = "; fracAns.display();
cout << "\nAgain(y/n)?: "; cin >> choice;
}
return 0;
}