编译错误"String does not name a type"

Compilation Error "String does not name a type"

本文关键字:name not type does 错误 String 编译      更新时间:2023-10-16

尽管程序中有"使用命名空间 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>标头:

#include <string>