c++ - 编译错误 “String does not name a type”

标签 c++ compiler-errors

尽管具有“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/

相关文章:

c++ - 如何保护类外用户可以修改的指针地址? C++

java - 为什么我的 public void Constructor {} 不能编译?

java - 实例和类语法

haskell - 没有最后一个参数的函数组成

java - "Code too large"Android Studio 中的错误。我该如何解决?

c++ - '.expression'的左侧必须具有class/struct/union

c++ - 这个函数应该返回什么类型的对象?

c++ - 将 std::chrono::system_clock::time_point::min() 转换为字符串时出现无效空指针错误

c++ - 扫雷。递归检查时的段错误

c++ - 找不到 MyClass.cpp