尽管具有“using namespace std;”,但出现错误“字符串未命名类型”;在程序中。
#ifndef SHAPE_H
#define SHAPE_H
using namespace std;
class Shape
{
public:
Shape();
virtual ~Shape();
string getShapeName();
void setShapeName(string shapeName);
virtual float calculateArea() = 0; //Calculates area of the shape
protected:
const float PI = 3.14159265;
private:
string m_ShapeName;
};
#endif // SHAPE_H_INCLUDED
最佳答案
您缺少<string>
header :
#include <string>
关于c++ - 编译错误 “String does not name a type”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44218944/