I wrote this program to demonstrate overloading a constructor, but I'm getting an error. Please tell me what's wrong so I can never again make this mistake, thanks
Error w/ gcc 3.2:
Here's the program:program.cpp: In function `int main(int, char**)':
program.cpp:50: request for member `DrawShape' in `theRect1()', which is of
non-aggregate type `Rectangle ()()'
Code:#include <iostream> using namespace std; class Rectangle { public: Rectangle (); Rectangle (int heigth, int width); ~Rectangle (); void DrawShape () const; private: int itsH; int itsW; }; Rectangle::Rectangle () { itsH = 5; itsW = 5; } Rectangle::Rectangle (int heigth, int width) { itsH = heigth; itsW = width; } Rectangle::~Rectangle () { } void Rectangle::DrawShape () const { for (int x = 0; x < itsW; x++) { for (int i = 0; i < itsH; i++) cout << "*"; cout << "\n"; } } int main (int argc, char *argv[]) { Rectangle theRect1 (); Rectangle theRect2 (6, 7); theRect1.DrawShape (); theRect2.DrawShape (); return 0; }



LinkBack URL
About LinkBacks



