私はタイプの長方形のオブジェクトを宣言しようとしているが、それは、これは形状クラスから継承Rectangleクラスである私は、このエラー未定義の参照
を示す保持:
class rectangle: public shape{
int width, height;
public:
rectangle();
void draw(int width, int height){
for(int i = 1; i <= height; i++){
for(int j = 1; j <= width; j++){
if(i == 1 && i == height)
cout<<"*";
else if(j == 1 && j == width)
cout<<"*";
else
cout<<" ";
}
cout<<endl;
}
}
};
これは、形状クラスである:
class shape
{
int x, y;
char letter;
public:
shape(int x, int y, char letter, int length){
int X = x;
int Y = y;
int L = letter;
}
void verLine(){
for(int i = 0; i < 5; i++){
cout<<"*"<<endl;
}
}
void horLine(){
for(int i = 0; i < 5; i++){
cout<<"*";
}
}
char setLetter(char letter){
int newLetter = letter;
return newLetter;
}
void gotoxy(int x, int y){
HANDLE hConsole;
COORD cursorLoe;
std::cout.flush();
cursorLoe.X = x;
cursorLoe.Y = y;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hConsole, cursorLoe);
}
};
これが主である:
int main()
{
rectangle r1;
cout<<endl;
r1.draw(5,5);
return 0;
}
あなたはデフォルトのコンストラクタを宣言したが、それを定義していない私は、問題は、私は長方形クラスで持っているデフォルトコンストラクタであると思うが、私はそれを
矩形のデフォルトのコンストラクタを定義していないようです。 –