武藤写真机报错代码_代码有错不知道如何改?

原问题:代码有错不知道如何改?
分类:编程开发 > 最后更新时间:【2016-12-11 19:28:30】
问题补充:

#include<iostream.h>

#define PI 3.14159

class Shape

{public:

virtual void printArea() = 0;

};

class Circle : public Shape

{public:

Circle(float Radius)

{

mRadius = Radius;

}

void printArea()

{

cout<<"The Circle's Area is "<<PI*mRadius*mRadius<<endl;

}

private:

float mRadius;

};

class Rectangle : public Shape

{public:

Rectangle(float Length, float Height)

{

mLength = Length;

mHeight = Height;

}

void printArea()

{

cout<<"The Rectangle's Area is "<<mLength*mHeight<<endl;

}

private:

float mLength, mHeight;

};

int main()

{

Circle mCircle(2.0);

mCircle.printArea();

Rectangle mRectangle(3.0, 4.0);

mRectangle.printArea();

return 0;

}

最佳答案

头文件包含改为 #include <iostream>

追答:
另外请使用std命名空间using namespace std;
  • 追答:
    你的那些cout、endl都是在命名空间里面的,如果不使用命名空间,就需要std::cout这样用
    最佳答案由网友  听枫2005  提供
  • 公告: 为响应国家净网行动,部分内容已经删除,感谢网友理解。
    18

    分享到:

    其他回答

    暂无其它回答!

      推荐