Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c+中的不可追踪错误+;涉及类的代码 我编写了一个C++程序,包含以下类:类形状、圆、椭圆、矩形、三角形。所有的类都是类Shape的一个子类。他们定义的语法很好,我看不到任何明显的错误。代码如下: #include "graphics.h" //#include <iostream> using namespace std; const float Pi = 3.141; float distance (int x1, int y1, int x2, int y2) { int x = x2 - x1; int y = y2 - y1; x = x * x; y = y * y; float total = x + y; float length = sqrt(total); return length; } class Shape { public: float area; virtual void Area () = 0; }; class Rectangle : public Shape { public: int length, width; virtual void Area () { area = length * width; } }; class Triangle : public Shape { public: float a, b, c; virtual void Area () { float s = ((a + b + c) / 2); area = sqrt(s * (s - a) * (s - b) * (s - c)); } }; class Ellipse : public Shape { public: int x, y; float a, b; virtual void Area () { area = Pi * a * b; } }; class Circle : public Shape { public: int x, y; //Centre float radius; virtual void Area () { area = Pi * radius * radius; } }; class Line { //implement zigzag within Line public: int x, y; //last point of line segment }; //Function paintInterface to initalize the paint viewport and textboxes within the viewport void paintInterface () { static int count = 0; //void initwindow (int width, int height, char * title) initwindow(1000, 800, "Paint"); //void setbkcolor(int color) setbkcolor(WHITE); //void setcolor(int color) setcolor (BLACK); //void setfillstyle(int pattern, int color) setfillstyle (1, WHITE); //void bar(int left, int top, int right, int bottom) bar (0, 0, 1000, 800); //void outtextxy (int x, int y, char *textstring) outtextxy (2, 5, "New"); //void rectangle(int left, int top, int right, int bottom) rectangle (0, 5, 35, 20); outtextxy (2, 25, "Circle"); rectangle (0, 25, 40, 40); outtextxy (2, 45, "Rectangle"); rectangle (0, 45, 67, 60); outtextxy (2, 65, "Triangle"); rectangle (0, 65, 55, 80); outtextxy (2, 85, "Ellipse"); rectangle (0, 85, 50, 100); outtextxy (2, 105, "Line"); rectangle (0, 105, 30, 120); outtextxy (2, 130, "COLORS"); setfillstyle (1, BLUE); bar (2, 150, 20, 160); setfillstyle (1, RED); bar (25, 150, 43, 160); setfillstyle (1, GREEN); bar (2, 170, 20, 180); setfillstyle (1, YELLOW); bar (25, 170, 43, 180); setfillstyle (1, WHITE); outtextxy (2, 190, "Undo"); rectangle (0, 190, 37, 205); outtextxy (2, 210, "Exit"); rectangle (0, 210, 37, 225); if (count == 0) { outtextxy (400, 300, "Welcome to Paint!"); delay(2000); count++; paintInterface (); } } int main () { Circle a; Rectangle b; Ellipse d; Triangle c; int x1, y1; float length; paintInterface (); int xcoord, ycoord; bool flag = true; while (flag) { while(!ismouseclick(WM_LBUTTONDOWN)) {} getmouseclick(WM_LBUTTONDOWN, xcoord, ycoord); if (((xcoord >= 0) && (xcoord <= 35)) && ((ycoord >= 5) && (ycoord <= 20))) { paintInterface (); } } #包括“graphics.h” //#包括 使用名称空间std; 常数浮点Pi=3.141; 浮动距离(整数x1、整数y1、整数x2、整数y2){ int x=x2-x1; int y=y2-y1; x=x*x; y=y*y; 浮动总数=x+y; 浮动长度=平方米(总); 返回长度; } 阶级形态{ 公众: 漂浮区; 虚空面积()=0; }; 类矩形:公共形状{ 公众: int长度、宽度; 虚空区(){ 面积=长度*宽度; } }; 类三角形:公共形状{ 公众: 浮子a、b、c; 虚空区(){ 浮动s=((a+b+c)/2); 面积=平方米(s*(s-a)*(s-b)*(s-c)); } }; 类椭圆:公共形状{ 公众: int x,y; 浮子a、b; 虚空区(){ 面积=Pi*a*b; } }; 类圆:公共形状{ 公众: int x,y;//中心 浮动半径; 虚空区(){ 面积=圆周率*半径*半径; } }; 类行{//在行内实现锯齿形 公众: int x,y;//线段的最后一点 }; //函数paintInterface可初始化视口中的绘制视口和文本框 void paintInterface(){ 静态整数计数=0; //void initwindow(整数宽度、整数高度、字符*标题) 初始化窗口(1000800,“油漆”); //无效设置颜色(内部颜色) 蓝色(白色); //void setcolor(int-color) 设置颜色(黑色); //void setfillstyle(int图案、int颜色) setfillstyle(1,白色); //空心条(左整数、上整数、右整数、下整数) 巴(0,0,1000,800); //void outtextxy(int x,int y,char*textstring) outtextxy(2,5,“新”); //空心矩形(左整数、上整数、右整数、下整数) 矩形(0,5,35,20); outtextxy(2,25,“圆”); 矩形(0,25,40,40); outtextxy(2,45,“矩形”); 矩形(0,45,67,60); outtextxy(2,65,“三角形”); 矩形(0,65,55,80); outtextxy(2,85,“椭圆”); 矩形(0,85,50,100); outtextxy(2105行); 矩形(0,105,30,120); outtextxy(2130,“颜色”); setfillstyle(1,蓝色); 巴(2,150,20,160);; setfillstyle(1,红色); 巴(25、150、43、160); setfillstyle(1,绿色); 巴(2,170,20,180);; setfillstyle(1,黄色); 巴(25170,43180); setfillstyle(1,白色); outtextxy(2190,“撤销”); 矩形(0,190,37,205); outtextxy(2210,“退出”); 矩形(0210,37225); 如果(计数=0){ outtextxy(400300,“欢迎使用绘画!”); 延迟(2000年); 计数++; paintInterface(); } } int main() { 圈a; 矩形b; 椭圆d; 三角形c; int-x1,y1; 浮子长度; paintInterface(); int xcoord,ycoord; 布尔标志=真; while(旗帜){ 而(!ismouseclick(WM_LBUTTONDOWN)){} getmouseclick(WM_LBUTTONDOWN、xcoord、ycoord); 如果(((xcoord>=0)&&(xcoord=5)&&&(ycoord_C++_Class_Abstract Class - Fatal编程技术网 =0)&&(xcoord=5)&&&(ycoord,c++,class,abstract-class,C++,Class,Abstract Class" /> =0)&&(xcoord=5)&&&(ycoord,c++,class,abstract-class,C++,Class,Abstract Class" />

c+中的不可追踪错误+;涉及类的代码 我编写了一个C++程序,包含以下类:类形状、圆、椭圆、矩形、三角形。所有的类都是类Shape的一个子类。他们定义的语法很好,我看不到任何明显的错误。代码如下: #include "graphics.h" //#include <iostream> using namespace std; const float Pi = 3.141; float distance (int x1, int y1, int x2, int y2) { int x = x2 - x1; int y = y2 - y1; x = x * x; y = y * y; float total = x + y; float length = sqrt(total); return length; } class Shape { public: float area; virtual void Area () = 0; }; class Rectangle : public Shape { public: int length, width; virtual void Area () { area = length * width; } }; class Triangle : public Shape { public: float a, b, c; virtual void Area () { float s = ((a + b + c) / 2); area = sqrt(s * (s - a) * (s - b) * (s - c)); } }; class Ellipse : public Shape { public: int x, y; float a, b; virtual void Area () { area = Pi * a * b; } }; class Circle : public Shape { public: int x, y; //Centre float radius; virtual void Area () { area = Pi * radius * radius; } }; class Line { //implement zigzag within Line public: int x, y; //last point of line segment }; //Function paintInterface to initalize the paint viewport and textboxes within the viewport void paintInterface () { static int count = 0; //void initwindow (int width, int height, char * title) initwindow(1000, 800, "Paint"); //void setbkcolor(int color) setbkcolor(WHITE); //void setcolor(int color) setcolor (BLACK); //void setfillstyle(int pattern, int color) setfillstyle (1, WHITE); //void bar(int left, int top, int right, int bottom) bar (0, 0, 1000, 800); //void outtextxy (int x, int y, char *textstring) outtextxy (2, 5, "New"); //void rectangle(int left, int top, int right, int bottom) rectangle (0, 5, 35, 20); outtextxy (2, 25, "Circle"); rectangle (0, 25, 40, 40); outtextxy (2, 45, "Rectangle"); rectangle (0, 45, 67, 60); outtextxy (2, 65, "Triangle"); rectangle (0, 65, 55, 80); outtextxy (2, 85, "Ellipse"); rectangle (0, 85, 50, 100); outtextxy (2, 105, "Line"); rectangle (0, 105, 30, 120); outtextxy (2, 130, "COLORS"); setfillstyle (1, BLUE); bar (2, 150, 20, 160); setfillstyle (1, RED); bar (25, 150, 43, 160); setfillstyle (1, GREEN); bar (2, 170, 20, 180); setfillstyle (1, YELLOW); bar (25, 170, 43, 180); setfillstyle (1, WHITE); outtextxy (2, 190, "Undo"); rectangle (0, 190, 37, 205); outtextxy (2, 210, "Exit"); rectangle (0, 210, 37, 225); if (count == 0) { outtextxy (400, 300, "Welcome to Paint!"); delay(2000); count++; paintInterface (); } } int main () { Circle a; Rectangle b; Ellipse d; Triangle c; int x1, y1; float length; paintInterface (); int xcoord, ycoord; bool flag = true; while (flag) { while(!ismouseclick(WM_LBUTTONDOWN)) {} getmouseclick(WM_LBUTTONDOWN, xcoord, ycoord); if (((xcoord >= 0) && (xcoord <= 35)) && ((ycoord >= 5) && (ycoord <= 20))) { paintInterface (); } } #包括“graphics.h” //#包括 使用名称空间std; 常数浮点Pi=3.141; 浮动距离(整数x1、整数y1、整数x2、整数y2){ int x=x2-x1; int y=y2-y1; x=x*x; y=y*y; 浮动总数=x+y; 浮动长度=平方米(总); 返回长度; } 阶级形态{ 公众: 漂浮区; 虚空面积()=0; }; 类矩形:公共形状{ 公众: int长度、宽度; 虚空区(){ 面积=长度*宽度; } }; 类三角形:公共形状{ 公众: 浮子a、b、c; 虚空区(){ 浮动s=((a+b+c)/2); 面积=平方米(s*(s-a)*(s-b)*(s-c)); } }; 类椭圆:公共形状{ 公众: int x,y; 浮子a、b; 虚空区(){ 面积=Pi*a*b; } }; 类圆:公共形状{ 公众: int x,y;//中心 浮动半径; 虚空区(){ 面积=圆周率*半径*半径; } }; 类行{//在行内实现锯齿形 公众: int x,y;//线段的最后一点 }; //函数paintInterface可初始化视口中的绘制视口和文本框 void paintInterface(){ 静态整数计数=0; //void initwindow(整数宽度、整数高度、字符*标题) 初始化窗口(1000800,“油漆”); //无效设置颜色(内部颜色) 蓝色(白色); //void setcolor(int-color) 设置颜色(黑色); //void setfillstyle(int图案、int颜色) setfillstyle(1,白色); //空心条(左整数、上整数、右整数、下整数) 巴(0,0,1000,800); //void outtextxy(int x,int y,char*textstring) outtextxy(2,5,“新”); //空心矩形(左整数、上整数、右整数、下整数) 矩形(0,5,35,20); outtextxy(2,25,“圆”); 矩形(0,25,40,40); outtextxy(2,45,“矩形”); 矩形(0,45,67,60); outtextxy(2,65,“三角形”); 矩形(0,65,55,80); outtextxy(2,85,“椭圆”); 矩形(0,85,50,100); outtextxy(2105行); 矩形(0,105,30,120); outtextxy(2130,“颜色”); setfillstyle(1,蓝色); 巴(2,150,20,160);; setfillstyle(1,红色); 巴(25、150、43、160); setfillstyle(1,绿色); 巴(2,170,20,180);; setfillstyle(1,黄色); 巴(25170,43180); setfillstyle(1,白色); outtextxy(2190,“撤销”); 矩形(0,190,37,205); outtextxy(2210,“退出”); 矩形(0210,37225); 如果(计数=0){ outtextxy(400300,“欢迎使用绘画!”); 延迟(2000年); 计数++; paintInterface(); } } int main() { 圈a; 矩形b; 椭圆d; 三角形c; int-x1,y1; 浮子长度; paintInterface(); int xcoord,ycoord; 布尔标志=真; while(旗帜){ 而(!ismouseclick(WM_LBUTTONDOWN)){} getmouseclick(WM_LBUTTONDOWN、xcoord、ycoord); 如果(((xcoord>=0)&&(xcoord=5)&&&(ycoord

c+中的不可追踪错误+;涉及类的代码 我编写了一个C++程序,包含以下类:类形状、圆、椭圆、矩形、三角形。所有的类都是类Shape的一个子类。他们定义的语法很好,我看不到任何明显的错误。代码如下: #include "graphics.h" //#include <iostream> using namespace std; const float Pi = 3.141; float distance (int x1, int y1, int x2, int y2) { int x = x2 - x1; int y = y2 - y1; x = x * x; y = y * y; float total = x + y; float length = sqrt(total); return length; } class Shape { public: float area; virtual void Area () = 0; }; class Rectangle : public Shape { public: int length, width; virtual void Area () { area = length * width; } }; class Triangle : public Shape { public: float a, b, c; virtual void Area () { float s = ((a + b + c) / 2); area = sqrt(s * (s - a) * (s - b) * (s - c)); } }; class Ellipse : public Shape { public: int x, y; float a, b; virtual void Area () { area = Pi * a * b; } }; class Circle : public Shape { public: int x, y; //Centre float radius; virtual void Area () { area = Pi * radius * radius; } }; class Line { //implement zigzag within Line public: int x, y; //last point of line segment }; //Function paintInterface to initalize the paint viewport and textboxes within the viewport void paintInterface () { static int count = 0; //void initwindow (int width, int height, char * title) initwindow(1000, 800, "Paint"); //void setbkcolor(int color) setbkcolor(WHITE); //void setcolor(int color) setcolor (BLACK); //void setfillstyle(int pattern, int color) setfillstyle (1, WHITE); //void bar(int left, int top, int right, int bottom) bar (0, 0, 1000, 800); //void outtextxy (int x, int y, char *textstring) outtextxy (2, 5, "New"); //void rectangle(int left, int top, int right, int bottom) rectangle (0, 5, 35, 20); outtextxy (2, 25, "Circle"); rectangle (0, 25, 40, 40); outtextxy (2, 45, "Rectangle"); rectangle (0, 45, 67, 60); outtextxy (2, 65, "Triangle"); rectangle (0, 65, 55, 80); outtextxy (2, 85, "Ellipse"); rectangle (0, 85, 50, 100); outtextxy (2, 105, "Line"); rectangle (0, 105, 30, 120); outtextxy (2, 130, "COLORS"); setfillstyle (1, BLUE); bar (2, 150, 20, 160); setfillstyle (1, RED); bar (25, 150, 43, 160); setfillstyle (1, GREEN); bar (2, 170, 20, 180); setfillstyle (1, YELLOW); bar (25, 170, 43, 180); setfillstyle (1, WHITE); outtextxy (2, 190, "Undo"); rectangle (0, 190, 37, 205); outtextxy (2, 210, "Exit"); rectangle (0, 210, 37, 225); if (count == 0) { outtextxy (400, 300, "Welcome to Paint!"); delay(2000); count++; paintInterface (); } } int main () { Circle a; Rectangle b; Ellipse d; Triangle c; int x1, y1; float length; paintInterface (); int xcoord, ycoord; bool flag = true; while (flag) { while(!ismouseclick(WM_LBUTTONDOWN)) {} getmouseclick(WM_LBUTTONDOWN, xcoord, ycoord); if (((xcoord >= 0) && (xcoord <= 35)) && ((ycoord >= 5) && (ycoord <= 20))) { paintInterface (); } } #包括“graphics.h” //#包括 使用名称空间std; 常数浮点Pi=3.141; 浮动距离(整数x1、整数y1、整数x2、整数y2){ int x=x2-x1; int y=y2-y1; x=x*x; y=y*y; 浮动总数=x+y; 浮动长度=平方米(总); 返回长度; } 阶级形态{ 公众: 漂浮区; 虚空面积()=0; }; 类矩形:公共形状{ 公众: int长度、宽度; 虚空区(){ 面积=长度*宽度; } }; 类三角形:公共形状{ 公众: 浮子a、b、c; 虚空区(){ 浮动s=((a+b+c)/2); 面积=平方米(s*(s-a)*(s-b)*(s-c)); } }; 类椭圆:公共形状{ 公众: int x,y; 浮子a、b; 虚空区(){ 面积=Pi*a*b; } }; 类圆:公共形状{ 公众: int x,y;//中心 浮动半径; 虚空区(){ 面积=圆周率*半径*半径; } }; 类行{//在行内实现锯齿形 公众: int x,y;//线段的最后一点 }; //函数paintInterface可初始化视口中的绘制视口和文本框 void paintInterface(){ 静态整数计数=0; //void initwindow(整数宽度、整数高度、字符*标题) 初始化窗口(1000800,“油漆”); //无效设置颜色(内部颜色) 蓝色(白色); //void setcolor(int-color) 设置颜色(黑色); //void setfillstyle(int图案、int颜色) setfillstyle(1,白色); //空心条(左整数、上整数、右整数、下整数) 巴(0,0,1000,800); //void outtextxy(int x,int y,char*textstring) outtextxy(2,5,“新”); //空心矩形(左整数、上整数、右整数、下整数) 矩形(0,5,35,20); outtextxy(2,25,“圆”); 矩形(0,25,40,40); outtextxy(2,45,“矩形”); 矩形(0,45,67,60); outtextxy(2,65,“三角形”); 矩形(0,65,55,80); outtextxy(2,85,“椭圆”); 矩形(0,85,50,100); outtextxy(2105行); 矩形(0,105,30,120); outtextxy(2130,“颜色”); setfillstyle(1,蓝色); 巴(2,150,20,160);; setfillstyle(1,红色); 巴(25、150、43、160); setfillstyle(1,绿色); 巴(2,170,20,180);; setfillstyle(1,黄色); 巴(25170,43180); setfillstyle(1,白色); outtextxy(2190,“撤销”); 矩形(0,190,37,205); outtextxy(2210,“退出”); 矩形(0210,37225); 如果(计数=0){ outtextxy(400300,“欢迎使用绘画!”); 延迟(2000年); 计数++; paintInterface(); } } int main() { 圈a; 矩形b; 椭圆d; 三角形c; int-x1,y1; 浮子长度; paintInterface(); int xcoord,ycoord; 布尔标志=真; while(旗帜){ 而(!ismouseclick(WM_LBUTTONDOWN)){} getmouseclick(WM_LBUTTONDOWN、xcoord、ycoord); 如果(((xcoord>=0)&&(xcoord=5)&&&(ycoord,c++,class,abstract-class,C++,Class,Abstract Class,我可以用g++添加一个'}来编译)'在main之后。我没有图形。但是。检查您在main之前包含的最后一个标题。是否缺少分号?对我有用:Post real code。总结main看起来像什么隐藏了问题。将其修剪到可以显示问题的最小值。不,我每天检查四次ch是我的代码,据我所知,没有缺少分号。在graphics.h

我可以用g++添加一个'}来编译)'在main之后。我没有图形。但是。

检查您在
main
之前包含的最后一个标题。是否缺少分号?对我有用:Post real code。总结
main
看起来像什么隐藏了问题。将其修剪到可以显示问题的最小值。不,我每天检查四次ch是我的代码,据我所知,没有缺少分号。在
graphics.h