473,569 Members | 2,542 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

probs with a simple program

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(Rect angle);
#include <iostream>
using namespace std;

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

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

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

private:
int itsWidth;
int itsHeight;
};

Rectangle::Rect angle(int width, int height)
{
itsWidth=width;
itsHeight=heigh t;
}

Rectangle::~Rec tangle() {}

void Rectangle::SetS ize(int width, int height)
{
itsWidth=width;
itsHeight=heigh t;
}

int DoMenu();
void DoDrawRect(Rect angle); // <<--HERES THE
PROBLEM!!!!!!!! !!!!!!!!
void DoGetArea(Recta ngle);
void DoGetPerim(Rect angle);

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

int choice=DrawRect ;
int fQuit=false;

while(!fQuit)
{
choice=DoMenu() ;
if (choice<DrawRec t || choice>Quit)
{
cout << "\nAuswahl ungueltig. Bitte neu versuchen.\n\n" ;
continue;
}
switch(choice)
{
case DrawRect:
DoDrawRect(theR ect);
break;
case GetArea:
DoGetArea(theRe ct);
break;
case GetPerim:
DoGetPerim(theR ect);
break;
case ChangeDimension s:
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(theR ect);
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(Rect angle theRect)
{
int height=theRect. GetHeight();
int width=theRect.G etWidth();
for(int i=0; i<height; i++)
{
for(int j=0; j<width; j++)
cout << "x";
cout << endl;
}
}

void DoGetArea(Recta ngle theRect)
{
int area=theRect.Ge tArea();
cout << "Flaeche: " << area << endl;
}

void DoGetPerim(Rect angle theRect)
{
int perim=theRect.G etPerim();
cout << "Umfang: " << perim << endl;
}

id really appreciate any help,
bye,
Claus
Jul 22 '05 #1
9 1427
Claus Nietzsche wrote in news:bs******** *****@news.t-online.com:
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(Rect angle);


[snip]
int main()
{
Rectangle theRect(30,5);

int choice=DrawRect ;
int fQuit=false;

while(!fQuit)
{
choice=DoMenu() ;
if (choice<DrawRec t || choice>Quit)
{
cout << "\nAuswahl ungueltig. Bitte neu versuchen.\n\n" ;
continue;
}
switch(choice)
{
case DrawRect:
DoDrawRect(theR ect);
break;
case GetArea:
DoGetArea(theRe ct);
break;
case GetPerim:
DoGetPerim(theR ect);
break;
case ChangeDimension s:
int newWidth, newHeight;
cout << "\nBitte geben Sie die Breite an: "; cin << newWidth;
cin >> newWidth;

cout << "\nBitte geben Sie die Hoehe an: "; cin << newHeight;
cin >> newHeight;

theRect.SetSize (newWidth, newHeight);
DoDrawRect(theR ect);
break;
case Quit:
fQuit=true;
cout << "\nVerlassen.\n ";
break;
default:
cout << "\nFehler beim Auswaehlen!\n";
fQuit=true;
break;
}
} /* end the while loop */
return 0;
}

[snip]

id really appreciate any help,
bye,
Claus


The above were the only error's I could find.

After applying the fixes it compiled and ran on 4 out of 4 of the
compilers I tried.

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
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.
WHAT error?
its in the line: void DoDrawRect(Rect angle);
#include <iostream>
using namespace std;

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

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

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

private:
int itsWidth;
int itsHeight;
};

Rectangle::Rect angle(int width, int height)
{
itsWidth=width;
itsHeight=heigh t;
}

Rectangle::~Rec tangle() {}

void Rectangle::SetS ize(int width, int height)
{
itsWidth=width;
itsHeight=heigh t;
}

int DoMenu();
void DoDrawRect(Rect angle); // <<--HERES THE
PROBLEM!!!!!!!! !!!!!!!!
void DoGetArea(Recta ngle);
void DoGetPerim(Rect angle);

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

int choice=DrawRect ;
int fQuit=false;

while(!fQuit)
{
choice=DoMenu() ;
if (choice<DrawRec t || choice>Quit)
{
cout << "\nAuswahl ungueltig. Bitte neu versuchen.\n\n" ;
continue;
}
switch(choice)
{
case DrawRect:
DoDrawRect(theR ect);
break;
case GetArea:
DoGetArea(theRe ct);
break;
case GetPerim:
DoGetPerim(theR ect);
break;
case ChangeDimension s:
int newWidth, newHeight;
cout << "\nBitte geben Sie die Breite an: ";
cin << newWidth;
This should probably be

cin >> newWidth;
cout << "\nBitte geben Sie die Hoehe an: ";
cin << newHeight;
And this
cin >> newHight;
theRect.SetSize (newWidth, newHeight);
DoDrawRect(theR ect);
break;
case Quit:
fQuit=true;
cout << "\nVerlassen.\n ";
break;
default:
cout << "\nFehler beim Auswaehlen!\n";
fQuit=true;
break;
}
You need another curly brace here, to close the "while" body:

}
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(Rect angle theRect)
{
int height=theRect. GetHeight();
int width=theRect.G etWidth();
for(int i=0; i<height; i++)
{
for(int j=0; j<width; j++)
cout << "x";
cout << endl;
}
}

void DoGetArea(Recta ngle theRect)
{
int area=theRect.Ge tArea();
cout << "Flaeche: " << area << endl;
}

void DoGetPerim(Rect angle theRect)
{
int perim=theRect.G etPerim();
cout << "Umfang: " << perim << endl;
}

id really appreciate any help,
bye,
Claus

Jul 22 '05 #3
first of all i wanna thank you for qour help.

so you mean that you didnt get any error message in the following line?
void DoDrawRect(Rect angle);???

which compilers did you try it on?
im using dev-c++ 4.9.8.0
Jul 22 '05 #4
the error message i get is the following:
C:/Documents and Settings/Albert/My Documents/C++/week1.cpp:38: variable or
field `DoDrawRect' declared void
C:/Documents and Settings/Albert/My Documents/C++/week1.cpp:38: invalid
conversion from `BOOL (*)(HDC__*, int, int, int, int)' to `int'

i changed the other mistakes (pretty dumb ones *g*)

but i still get that error!!

"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:76EGb.1349 52$8y1.414093@a ttbi_s52...
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
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.


WHAT error?
its in the line: void DoDrawRect(Rect angle);
#include <iostream>
using namespace std;

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

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

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

private:
int itsWidth;
int itsHeight;
};

Rectangle::Rect angle(int width, int height)
{
itsWidth=width;
itsHeight=heigh t;
}

Rectangle::~Rec tangle() {}

void Rectangle::SetS ize(int width, int height)
{
itsWidth=width;
itsHeight=heigh t;
}

int DoMenu();
void DoDrawRect(Rect angle); // <<--HERES THE
PROBLEM!!!!!!!! !!!!!!!!
void DoGetArea(Recta ngle);
void DoGetPerim(Rect angle);

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

int choice=DrawRect ;
int fQuit=false;

while(!fQuit)
{
choice=DoMenu() ;
if (choice<DrawRec t || choice>Quit)
{
cout << "\nAuswahl ungueltig. Bitte neu versuchen.\n\n" ;
continue;
}
switch(choice)
{
case DrawRect:
DoDrawRect(theR ect);
break;
case GetArea:
DoGetArea(theRe ct);
break;
case GetPerim:
DoGetPerim(theR ect);
break;
case ChangeDimension s:
int newWidth, newHeight;
cout << "\nBitte geben Sie die Breite an: ";
cin << newWidth;


This should probably be

cin >> newWidth;
cout << "\nBitte geben Sie die Hoehe an: ";
cin << newHeight;


And this
cin >> newHight;
theRect.SetSize (newWidth, newHeight);
DoDrawRect(theR ect);
break;
case Quit:
fQuit=true;
cout << "\nVerlassen.\n ";
break;
default:
cout << "\nFehler beim Auswaehlen!\n";
fQuit=true;
break;
}


You need another curly brace here, to close the "while" body:

}
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(Rect angle theRect)
{
int height=theRect. GetHeight();
int width=theRect.G etWidth();
for(int i=0; i<height; i++)
{
for(int j=0; j<width; j++)
cout << "x";
cout << endl;
}
}

void DoGetArea(Recta ngle theRect)
{
int area=theRect.Ge tArea();
cout << "Flaeche: " << area << endl;
}

void DoGetPerim(Rect angle theRect)
{
int perim=theRect.G etPerim();
cout << "Umfang: " << perim << endl;
}

id really appreciate any help,
bye,
Claus


Jul 22 '05 #5
Claus Nietzsche wrote in news:bs******** ****@news.t-online.com:
first of all i wanna thank you for qour help.

so you mean that you didnt get any error message in the following line?
void DoDrawRect(Rect angle);???
That is correct.

which compilers did you try it on?
im using dev-c++ 4.9.8.0


That isn't a compiler its an IDE, it probably uses gcc as its compiler.

Read your Dev-c++ docs/help to find out what compiler its using.

One of the compiler's I tried was gcc 3.2.3.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #6
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
first of all i wanna thank you for qour help.

so you mean that you didnt get any error message in the following line?
void DoDrawRect(Rect angle);???
No, we apparently didn't.
which compilers did you try it on?
Comeau online test-drive.
im using dev-c++ 4.9.8.0


Shouldn't be of any difference.

I have a suspicion, however. If your compiler includes <windows.h>
somewhere behind the scenes, unbeknownst to you, you may get some
kind of definition interference from MS Windows types.

Victor
Jul 22 '05 #7
so,
do u have any kind of advice for me?
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:kmEGb.4783 59$275.1377191@ attbi_s53...
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
first of all i wanna thank you for qour help.

so you mean that you didnt get any error message in the following line?
void DoDrawRect(Rect angle);???


No, we apparently didn't.
which compilers did you try it on?


Comeau online test-drive.
im using dev-c++ 4.9.8.0


Shouldn't be of any difference.

I have a suspicion, however. If your compiler includes <windows.h>
somewhere behind the scenes, unbeknownst to you, you may get some
kind of definition interference from MS Windows types.

Victor

Jul 22 '05 #8
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
so,
do u have any kind of advice for me?
If you look for advice of _any_ kind, here it is: change the compiler.


"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:kmEGb.4783 59$275.1377191@ attbi_s53...
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
first of all i wanna thank you for qour help.

so you mean that you didnt get any error message in the following line? void DoDrawRect(Rect angle);???


No, we apparently didn't.
which compilers did you try it on?


Comeau online test-drive.
im using dev-c++ 4.9.8.0


Shouldn't be of any difference.

I have a suspicion, however. If your compiler includes <windows.h>
somewhere behind the scenes, unbeknownst to you, you may get some
kind of definition interference from MS Windows types.

Victor


Jul 22 '05 #9
allright,
thx for all your help,
i really appreciate it.

i will try to use gnu 3.3.2 now
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:wTEGb.6595 97$Fm2.578933@a ttbi_s04...
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
so,
do u have any kind of advice for me?


If you look for advice of _any_ kind, here it is: change the compiler.


"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:kmEGb.4783 59$275.1377191@ attbi_s53...
"Claus Nietzsche" <cl*****@hotmai l.com> wrote...
> first of all i wanna thank you for qour help.
>
> so you mean that you didnt get any error message in the following line? > void DoDrawRect(Rect angle);???

No, we apparently didn't.

> which compilers did you try it on?

Comeau online test-drive.

> im using dev-c++ 4.9.8.0

Shouldn't be of any difference.

I have a suspicion, however. If your compiler includes <windows.h>
somewhere behind the scenes, unbeknownst to you, you may get some
kind of definition interference from MS Windows types.

Victor



Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2100
by: lurkerboy | last post by:
I'm trying to open a file to read some stock market data in the metastock format. I can't figure out how to get it to read the correct bytes into the struct that I have defined in accordance to the Metastock data format. Can someone help a rookie out? lurkerboy
1
1971
by: Arijit Chatterjee | last post by:
Hi Everybody, I am facing another probs. I have created a trigger for table Tab1 for perticular column col1 for checking value ranges.But at time for using insert statement it is working fine but when I am importing data from flat file through DTS the trigger is not working.How to solve this. Regards Arijit Chatterjee
2
2265
by: jim | last post by:
I'm trying to find the best way to allow web visitors to download text files (.txt, .wri & .zap file extensions). I'm having some luck. I say some because the open/save box opens with IE but not Netscape. On Netscape rather than give the user the save option it simply displays the file. I also see problems on the mac platform - no save box -...
2
4452
by: andrewcw | last post by:
Seems it should be simple. I had problems with a larger class and the newsgroup suggested something I also tried. So I pruned my class to see if I could find out what could be wrong, Still dont know. This snippet is easily dropped into any project, THANKS namespace QCLoader { public class disksetitem {
12
1383
by: EricJ | last post by:
back at the saturday job ;) all help is welcome ( if there is an other way of doing this i don't mind as long as it works) i have to compose an image in code. I have a background image (a bitmap but i can convert it if needed) and an image of a cross (bit like the close button on an xp form) i have to place the cross a limited nr of...
7
2167
by: polecat | last post by:
Im new to .NET and I am having probs with this Every time I reload the form the same data is repeated again.... Done reading on msdn and another forum cant figure out why the DsProds.Tables(0).Clear() is not clearing the first lot of data ? ' This is in my load event
0
1133
by: uninvitedm | last post by:
I had the following code to connect to a site on a server. It worked fine, now the server is using https, which causes the error javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Couldn't find trusted certificate java.util.Properties propSy = System.getProperties(); ...
4
1248
by: Enkidu | last post by:
I've not much experience of C#, so maybe someone can help me with this little problem? I've discovered that an event handler seems to be able to call methods in its own class, but not in other classes even if they are 'in scope' (if that is the correct term). For instance: private void button1_Click(object sender, EventArgs e)
0
1153
by: bkpatel | last post by:
get Join the PHP community and share ur probs - soln <table border=0 style="background-color: #fff; padding: 5px;" cellspacing=0> <tr><td> <img src="http://groups.google.com/groups/img/3nb/groups_bar.gif" height=26 width=132 alt="Google Groups"> </td></tr> <tr><td style="padding-left: 5px">
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.