我做了這段代碼,遇到了一個我不明白它是什么的錯誤。我在 VS 代碼中運行該程式,編譯成功,但在 GFG 門戶中出現編譯錯誤。
#include <iostream>
using namespace std;
/*
* Create classes Rectangle and RectangleArea
*/
int l,b, result;
class Rectangle
{
public:
void display()
{
cout<<l <<" "<< b<<endl;
}
};
class RectangleArea : public Rectangle
{
public:
void read_input()
{
cin >> l >> b;
}
void display()
{
result = l* b;
cout<<result;
}
};
int main()
{
/*
* Declare a RectangleArea object
*/
RectangleArea r_area;
/*
* Read the width and height
*/
r_area.read_input();
/*
* Print the width and height
*/
r_area.Rectangle::display();
/*
* Print the area
*/
r_area.display();
return 0;
}
這是我得到的錯誤。幫我。
這是我正在做的GFG問題。
uj5u.com熱心網友回復:
不要粘貼主要功能,門戶網站將其再次添加到源中,因此它會出現兩次。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/488787.html
下一篇:在C 類中初始化另一個類
