未指定字符串

String not specified

本文关键字:字符串 未指定      更新时间:2023-10-16

我正在尝试创建一个包含一堆不同类的程序。 不知何故,尽管#include < string>已被多次使用,但我仍然遇到缺少类型说明符的错误。

我不知道在哪里。 有谁知道这个问题可能起源于哪里,或者如果没有,我可以采取任何步骤来尝试调试这个问题?

我很抱歉这个长帖子,我只是不想遗漏任何东西。

主.cpp:

#include <iostream>
#include "ATP.cpp"
#include "AtlasObject.cpp"
#include "MAP.cpp"
#include "AtlasObjectFactory.cpp"
using namespace std;
int main()
{
    cout << "Hello World!" << endl;
    return 0;
}

AtlasObject.cpp:

#ifndef ATLASOBJECT_CPP
#define ATLASOBJECT_CPP
#include <string>

class AtlasObject{
public:
    virtual void create();
protected:
    string uid;
    string label;
    int colorR;
    int colorB;
    int colorG;
    char *data;
    int isEncrypted;
    void set_uid(string id);
    void set_label(string l);
    void set_color(int r, int b, int g);
    void set_data(char* inData);
    void set_isEncrypted(int encrypted);
    string get_uid();
    string get_label();
    string get_color();
    vchar* get_data();
    int get_isEncrypted();
};
void AtlasObject::set_uid(string id) {}
void AtlasObject::set_label(string l) {}
void AtlasObject::set_color(int r, int b, int g) {}
void AtlasObject::set_data(char *inData) {}
void AtlasObject::set_isEncrypted(int encrypted) {}
string AtlasObject::get_uid() {}
string AtlasObject::get_label() {}
string AtlasObject::get_color() {}
char* AtlasObject::get_data() {}
int AtlasObject::get_isEncrypted() {}
#endif

AtlasObjectFactory.cpp:

#ifndef ATLASOBJECTFACTORY_CPP
#define ATLASOBJECTFACTORY_CPP
#include "AtlasObject.cpp"
class AtlasObjectFactory
{
public:
    static void getInstance();
    ~AtlasObjectFactory();
    AtlasObject* createObject(int obj_type);
private:
    AtlasObjectFactory();
};
#endif

ATP.cpp:

#ifndef ATP_CPP
#define ATP_CPP
#include <string>
#include <map>
#include "AtlasObject.cpp"
using namespace std;
struct Image{
    string Dim;
    string Vox;
    string Ori;
    char* data;
};
class APT
{
private:
    map<string,int> listOfMaps;
    Image referenceImage;
protected:
};
#endif // AtlasObject.cpp

MAP.cpp:

#ifndef MAP_CPP
#define MAP_CPP
#include "AtlasObject.cpp"
class MAP : public AtlasObject
{
public:
    void create();
};
void MAP::create()
{
}
#endif

在你的 AtlasObject.cpp 文件中,你应该添加这个:

using std::string;

由于std::string是在命名空间std下创建的,因此您没有指定using namespace std