我無法解決3錯誤。項目實施是正確的,但不知道如何擺脫3個錯誤C++程序錯誤
# include <iostream.h>
# include < conio.h>
void main() {
class coord {
float x;
float y;
//Constructor
coord(float init_x,float init_y) {
x= init_x;
y= init_y;
}
void set(float f1, float f2) {
x = f1;
y = f2;
}
float get_x() {return x;}
float get_y() {return y;}
virtual void plot() {
cout<<x;
cout<<y;
};
class 3d_coord: public coord {
float z;
//constructor
3d_coord(float init_x,float init_y,float init_z): coord(init_x,init_y) {
z= init_z;
}
void set(float f1,float f2,float f3) {
coord::set(f1, f2); z = f3;
}
float get_z() { return z; }
virtual void plot() {
coord::plot();
cout<<z;
};
int test
void *ptr;
cin>>test;
coord a(1.1, 2.2);
3d_coord b(3.0, 4.0, 5.0);
if (test)
ptr = &a;
else
ptr = &b;
ptr-> plot();
}
}
請正確格式化 – 2010-10-01 03:23:50
通過將四個空格中的每一條戰線請格式化你的代碼線。如果選擇要格式化的文本,「0101」按鈕會自動執行此操作。謝謝! – 2010-10-01 03:24:58
堆棧溢出社區不是C++編譯器。如果你的C++編譯器給你提供了錯誤,你應該指出那些錯誤是什麼(請確切的文字!),以及編譯器說錯誤的源頭在哪裏。 – 2010-10-01 03:25:14