简体   繁体   English

'int main()' 之前在这里定义

[英]‘int main()’ previously defined here

I did this code and faced an error that I can't understand what it is.我做了这段代码,遇到了一个我不明白它是什么的错误。 I run this program in VS code and compilation was successful but getting an compilation error in GFG portal.我在 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;
  }

And this is the error I got.这是我得到的错误。 Help me.帮我。

This is the GFG problem that I'm doing. 这是我正在做的GFG问题。

不要粘贴主要功能,门户网站将其再次添加到源中,因此它会出现两次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM