What is wrong with this simple code?

Started by
1 comment, last by Fredric 24 years, 2 months ago
Once again, I have run into a block at has stopped me from proceeding on with my programming studies. The following piece of code is giving me trouble- the member function declaration, void DrawShape(USHORT width, USHORT height, BOOL UseCurrentValues = FALSE) const;, comes up on the compiler as an error saying that it was expected... whatever that means. Can anyone help me out here, I know it''s easy... I just can''t see the problem! #include ''iostream.h'' typedef unsigned short int USHORT ; enum BOL { FALSE, TRUE }; class Rectangle { public: Rectangle(USHORT width, USHORT height); ~Rectangle() {} void DrawShape(USHORT aWidth, USHORT aHeight, BOOL UseCurrentValues = FALSE) const; private: USHORT itsWidth; USHORT itsHeight; }; Rectangle::Rectangle(USHORT width, USHORT height): itsWidth(width), itsHeight(height) {} void Rectangle::DrawShape(USHORT width, USHORT height, BOOL UseCurrentValues) const { int printWidth; int printHeight; if (UseCurrentValues == TRUE) { printWidth = itsWidth; // use current class values printHeight = itsHeight; } else { printWidth = width; // use parameter values printHeight = height; } for (int i=0; i<printHeight; i++) { for (int j=0; j<printWidth; j++) { cout << "*"; } cout << "\n"; } } int main() { Rectangle theRect(30,5); cout << "DrawShape(0,0,TRUE)...\n"; theRect.DrawShape(0,0,TRUE); cout << "\nDrawShape(40,2)...\n"; theRect.DrawShape(40,2); return 0; }
3D Math- The type of mathematics that'll put hair on your chest!
Advertisement
I didn''t actually have time to check your code, and it might be a fluke, but you use:

enum BOL { FALSE, TRUE };

And then declare functions to take "BOOL"s.


Lack
Lack
Christianity, Creation, metric, Dvorak, and BeOS for all!
LOL you got it..... crap! Gr, I can''t believe I made such a stupid mistake!! I apologise for wasting your time... that was so stupid...
3D Math- The type of mathematics that'll put hair on your chest!

This topic is closed to new replies.

Advertisement