Been working on this project for last 2 nights. Cant get rid of this error message on my last method PAIR::area() . It's defined at the bottom of my program.
Everything else compiles... builds... executes just fine. Rusty on the basics and trying to figure out methods.... here is my error message:
error C2601: 'area' : local function definitions are illegal
Error executing cl.exe.
It sounds obvious but I think I'm just a little blurry eyed. Project is due tonight (Thur) at 6pm. I think I need to go start at chapter one again It's has to be something dumb I'm doing.
Any help appreciated.
class PAIR
{private:
int a;
int b;
public:
void print();
PAIR();
PAIR(int);
PAIR(int,int);
~PAIR();
void swap();
int diff();
int big();
int area();
};
int main()
{
PAIR c, d(2), e(12,13);
int ans;
c.print();
d.print();
e.print();
d.swap();
d.print();
e.swap();
e.print();
ans = c.diff();
cout << "\nThe answer to c.diff() is " << ans << endl;
int big = e.big () ;
cout << "\nThe larger number of e.big() is " << big << endl << endl;
return 0;
}
PAIR::PAIR()
{
a = 2;
b = 3;
}
void PAIR::print()
{cout << a << " " << b << endl;}
PAIR:: ~PAIR()
{
cout << "Display Destructor Message" << endl;
}
PAIR::PAIR(int p1)
{a=p1;
b=p1;}
PAIR::PAIR(int p1,int p2)
{
a=p1;
b=p2;
}
void PAIR::swap()
{
int c;
c=a;
a=b;
b=c;
}
int PAIR::diff()
{
return b - a;
}
int PAIR::big()
{
if (a > b)
{
return a;
}
else
{
return b;
}
int PAIR::area()
{
int z;
z=(a*b);
{
return z;
}
}
}