本文介绍了probs用一个简单的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时删除!! 嘿人, i写了这个程序,但我编译它有麻烦。 我的编译器一直在给我这一行的错误信息,我不能 找出原因。 它在行中:void DoDrawRect(Rectangle); #include< iostream> 使用命名空间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); 私人: 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 问题!!!!!!!!!!!!!!!! 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" ;; 继续; } 开关(选择) { 案例DrawRect: DoDrawRect(theRect); 休息; 案例GetArea: DoGetArea(theRect); 休息; 案例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退出: fQuit = true; cout<< \ nVerlassen.\ n;; 休息; 默认值: cout<< \ nFeFehler beim Auswaehlen!\ n" ;; fQuit = true; 休息; } 返回0; } int DoMenu() { int choice; cout<< " \ n \ n **** Menue **** \ n"; cout<< "(1)Rechteck zeichnen\\\"; cout<< (2)Flaeche \ n; cout<< (3)Umfang \ n; cout<< (4)Groesse veraendern\\\; cout<< "(5)Beenden\\\"; cin>>选择; 返回选择; } void DoDrawRect(Rectangle theRect) { int height = theRect.GetHeight(); int width = theRect.GetWidth(); for(int i = 0; i<身高; i ++) { for(int j = 0; j< width; j ++) cout<< x; cout<<结束; } } 无效DoGetArea(矩形theRect) { int area = theRect.GetArea(); cout<< Flaeche: <<面积<<结束; } void DoGetPerim(Rectangle theRect) { int perim = theRect .GetPerim(); cout<< Umfang: << perim<<结束; } id非常感谢任何帮助, 再见, Claus 解决方案 Claus Nietzsche在新闻中写道:bs ************* @ news.t-online.com: 嘿,人们,我编写了这个程序,但我编译它有麻烦。我的编译器一直在给我这一行错误信息,我不能找出原因。它在行中:void DoDrawRect(Rectangle); [snip] int main () {矩形theRect(30,5); int choice = DrawRect; int fQuit = false; while (!fQuit) {选择= DoMenu(); if(选择< DrawRect ||选择>退出) { cout<< \ nAuswahl ungueltig。 Bitte neu versuchen.\\\\ n" ;; 继续; } 切换(选择)案例DrawRect: DoDrawRect(theRect ); 休息; 案例GetArea: DoGetArea(theRect); 休息; 案例GetPerim: DoGetPerim(theRect); 破坏; 案例ChangeDimensions: 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(theRect); break; case Quit: fQuit = true; cout<< \ nVerlassen.\ n;; 休息; 默认: cout<< \ nFeFehler beim Auswaehlen!\ n;; fQuit = true; 休息; } } / *结束了循环* / 返回0; } [snip] 我非常感谢任何帮助, 以上是我能找到的唯一错误。 应用修复后,它编译并运行了我试过的4个 编译器中的4个。 HTH。 Rob。 - http://www.victim-prime.dsl.pipex.com/ " Claus Nietzsche" < CL ***** @ hotmail.com>写道... 嘿,人们,我编写了这个程序,但我编译它有麻烦。我的编译器一直给我这一行的错误信息,我不能找出原因。 什么错误? 它在行中:void DoDrawRect(Rectangle); #include< iostream> 使用命名空间std; 枚举选择{DrawRect = 1,GetArea,GetPerim,ChangeDimensions,Quit}; 类Rectangle { public : Rectangle(int width,int height); ~Rectangle(); int GetWidth(){return itsWidth;} int GetHeight(){return itHeight;} int GetArea(){return(itsWidth * itsHeight);} int GetPerim(){return(2 * itsWidth + 2 * itsHeight);} void SetSize(int width ,int height); 私有: 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 问题!!!!!!!!!!!!!!!! void DoGetArea(Rectangle); void DoGetPerim(Rectangle) ; int main() {矩形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" ;; 继续; } 切换(选择)案例DrawRect: DoDrawRect(theRect ); 休息; 案例GetArea: DoGetArea(theRect); 休息; 案例GetPerim: DoGetPerim(theRect); 破坏; 案例ChangeDimensions: int newWidth,newHeight; cout<< \ nBitte geben Sie die Breite an:" ;; cin<< newWidth; 这应该是 cin>> newWidth; cout<< \ nBitte geben Sie die Hoehe an:" ;; cin<< newHeight; 这个 cin>> newHight; theRect.SetSize(newWidth,newHeight); DoDrawRect(theRect); break; case Quit: fQuit = true; cout<< \ nVerlassen.\ n;; 休息; 默认: cout<< \ nFeFehler beim Auswaehlen!\ n" ;; fQuit = true; 休息; } 你需要另一个大括号,关闭while正文: } 返回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\\\; cout<< "(5)Beenden\\\"; cin>>选择; 返回选择; 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: <<面积<< endl; } void DoGetPerim(Rectangle theRect) {perim = theRect.GetPerim(); cout<< Umfang: << perim<<任务帮助,再见,克劳斯 首先,我想感谢你的帮助。 所以你的意思是你没有收到以下行中的任何错误信息? void DoDrawRect(Rectangle); 编译器你试过它吗? 即时使用dev-c ++ 4.9.8.0 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 cantfigure 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 THEPROBLEM!!!!!!!!!!!!!!!!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 解决方案 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(Rectangle);[snip] 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;cin >> newWidth; cout << "\nBitte geben Sie die Hoehe an: "; cin << newHeight;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; }} /* end the while loop */ return 0; }[snip] id really appreciate any help, bye, ClausThe above were the only error''s I could find.After applying the fixes it compiled and ran on 4 out of 4 of thecompilers I tried.HTH.Rob.-- http://www.victim-prime.dsl.pipex.com/"Claus Nietzsche" <cl*****@hotmail.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(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;This should probably becin >> newWidth; cout << "\nBitte geben Sie die Hoehe an: "; cin << newHeight;And thiscin >> newHight; theRect.SetSize(newWidth, newHeight); DoDrawRect(theRect); 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(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, Clausfirst 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(Rectangle);???which compilers did you try it on?im using dev-c++ 4.9.8.0 这篇关于probs用一个简单的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 08:51