probs with a simple program

From: Claus Nietzsche (claus.n_at_hotmail.com)
Date: 12/25/03


Date: Thu, 25 Dec 2003 15:31:33 +0100

hey people,
i wrote this program, but i have troubles compiling it.
my compiler keeps giving me error messages in this one line, and i cant
figure out why.
its in the line: void DoDrawRect(Rectangle);

#include <iostream>
using namespace std;

enum choice { DrawRect = 1, GetArea, GetPerim, ChangeDimensions, Quit};

class Rectangle
{
    public:
        Rectangle(int width, int height);
        ~Rectangle();

        int GetWidth() {return itsWidth;}
        int GetHeight() {return itsHeight;}
        int GetArea() {return (itsWidth*itsHeight);}
        int GetPerim() {return (2*itsWidth+2*itsHeight);}
        void SetSize(int width, int height);

    private:
        int itsWidth;
        int itsHeight;
};

Rectangle::Rectangle(int width, int height)
{
    itsWidth=width;
    itsHeight=height;
}

Rectangle::~Rectangle() {}

void Rectangle::SetSize(int width, int height)
{
    itsWidth=width;
    itsHeight=height;
}

int DoMenu();
void DoDrawRect(Rectangle); // <<--HERES THE
PROBLEM!!!!!!!!!!!!!!!!
void DoGetArea(Rectangle);
void DoGetPerim(Rectangle);

int main()
{
    Rectangle theRect(30,5);

    int choice=DrawRect;
    int fQuit=false;

    while(!fQuit)
    {
        choice=DoMenu();
        if (choice<DrawRect || choice>Quit)
        {
            cout << "\nAuswahl ungueltig. Bitte neu versuchen.\n\n";
            continue;
        }
        switch(choice)
        {
            case DrawRect:
                DoDrawRect(theRect);
                break;
            case GetArea:
                DoGetArea(theRect);
                break;
            case GetPerim:
                DoGetPerim(theRect);
                break;
            case ChangeDimensions:
                int newWidth, newHeight;
                cout << "\nBitte geben Sie die Breite an: ";
                cin << newWidth;
                cout << "\nBitte geben Sie die Hoehe an: ";
                cin << newHeight;
                theRect.SetSize(newWidth, newHeight);
                DoDrawRect(theRect);
                break;
            case Quit:
                fQuit=true;
                cout << "\nVerlassen.\n";
                break;
            default:
                cout << "\nFehler beim Auswaehlen!\n";
                fQuit=true;
                break;
        }
    return 0;
}

int DoMenu()
{
    int choice;
    cout << "\n\n**** Menue ****\n";
    cout << "(1) Rechteck zeichnen\n";
    cout << "(2) Flaeche\n";
    cout << "(3) Umfang\n";
    cout << "(4) Groesse veraendern\n";
    cout << "(5) Beenden\n";

    cin >> choice;
    return choice;
}

void DoDrawRect(Rectangle theRect)
{
    int height=theRect.GetHeight();
    int width=theRect.GetWidth();
    for(int i=0; i<height; i++)
    {
        for(int j=0; j<width; j++)
            cout << "x";
        cout << endl;
    }
}

void DoGetArea(Rectangle theRect)
{
    int area=theRect.GetArea();
    cout << "Flaeche: " << area << endl;
}

void DoGetPerim(Rectangle theRect)
{
    int perim=theRect.GetPerim();
    cout << "Umfang: " << perim << endl;
}

id really appreciate any help,
bye,
Claus



Relevant Pages