我在一个类中有自己的对象的向量。但是当我想用这个向量做某事时,我有错误:/
game.h
SELECT DISTINCT ip
FROM `ipAll`
WHERE tempDate = CURDATE();
game.cpp
#include "renderSystem.h" //there only #include "console_color.h"
#include "level.h" //there only #include "renderSystem.h"
#include "gameObject.h"
class Game {
vector<GameObject> objects;
//something
public:
Game();
//something
};
gameObject.h
void Game::initialize() {
GameObject playerObject(GameObjectType_Player);
objects.insert(objects.end(), playerObject);
//something
}
错误是(我不能给你记录,因为它们是俄语:/)
#include "renderSystem.h"
#include "level.h"
class GameObject {
//something
public:
GameObject(GameObjectType _type);
GameObject() : GameObject(GameObjectType_None) {};
//something
};
我查了#includes,但可能是我傻了:/
在每个文件中我都有#pragma一次
在renderSystem和level我写的只包括
WTF?
Visual studio 2015
//我早上0:43,所以可能只需要睡觉:/
答案 0 :(得分:0)
这里有两个问题,一个,你不包括矢量头文件。第二个是vector类在C ++中的std :: namespace中。以下是两种可能的修复方法。
#include <vector> /* STL vector */
#include "renderSystem.h" //there only #include "console_color.h"
#include "level.h" //there only #include "renderSystem.h"
#include "gameObject.h"
class Game {
private:
std::vector<GameObject> objects;
public:
Game();
};
或者
#include <vector> /* STL vector */
#include "renderSystem.h" //there only #include "console_color.h"
#include "level.h" //there only #include "renderSystem.h"
#include "gameObject.h"
using namespace std;
class Game {
vector<GameObject> objects;
//something
public:
Game();
//something
};