| | |
Last CLASS method needs help... PAIR::area()
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
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.
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.
C++ Syntax (Toggle Plain Text)
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; } } }
•
•
•
•
.
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; } } // this was missing int PAIR::area() { int z; z=(a*b); { return z; } } // } // this is extra brace
The links for the above IDE can be found at teh top of this forum in the thread named "Starting C".
Hope it helped, bye.
I don't accept change; I don't deserve to live.
![]() |
Similar Threads
- Stopping a very time consuming class method's execution on tomcat server using JSP. (JSP)
- definition of a method (Java)
- Basic problem calling methods within a class (Java)
Other Threads in the C++ Forum
- Previous Thread: call to TCL script from C++ code
- Next Thread: Reading in file input up to newline
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






