What is wrong with this simple code?
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!
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
enum BOL { FALSE, TRUE };
And then declare functions to take "BOOL"s.
Lack
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement