c++如何跳过数值输入

我想在圆的时候跳过第二个数值的输入
无法跳过这个输入,并且我设置了length的初始值为零 但我还是必须手动输入0
#include

using namespace std;

class shaped
{
    double width,length;
    public:
    shaped(){width = 0;length = 0;}
    double getWidth(){return width;}
    double getLength(){return length;}
    void get_data()
    {
      cin>>width;
      cin>>length;
      if(!cin.good())
      {
        cin.clear();
        length=0;
      }
    }
    virtual void display_area()
    {

    }
};

class triangle:public shaped
{
    public :
    void display_area()
    {
      cout<<"Area of triangle = "<<getWidth()*getLength()<class rectangle:public shaped
{
    public:
    void display_area()
    {
      cout<<"Area of rectangle = "<<getWidth()*getLength()/2<class circle:public shaped
{
    public:
    void display_area()
    {
       cout<<"Area of circle = "<<3.1416*getWidth()*getWidth()<int main()
{
    triangle t;
    rectangle r;
    circle c;

    cout<<"Enter the value of x & y for triangle :";
    t.get_data();
    cout<<"Enter the value of x & y for rectangle :";
    r.get_data();
    cout<<"Enter the value of radius for circle :";
    c.get_data();

    t.display_area();
    r.display_area();
    c.display_area();


    return 0;
}

我试过了,但不知道为什么不行
只需要能在圆形时跳过第二个值的输入直接进入下一步就行

删除cin>>length

在园的类里重载getdata

不成熟的小建议, 程序逻辑有问题, 这种继承比较乱, 基类数据成员和派生类数据成员逻辑对不上, 建议基类只做公用接口, 和数据成员有关的放在派生类中.

当然, 如果就是要这种逻辑, 那就在基类多加一个只 cin wide的函数, 如果在派生类中重载, 基类的私有成员必须变为protect, 否则无法直接访问, 也就无法改变.