我得到std :: vector错误我从来没有听说过,无法找到任何有关它。C++矢量语法错误
ShootManager.h
#pragma once
#include "VGCVirtualGameConsole.h"
#include "Shot.h"
#include <vector>
using namespace std;
class ShootManager
{
public:
ShootManager();
~ShootManager();
void Destroy(int ShotNr);
void Update();
void Draw();
void Fire(Shot* shot);
vector<Shot*> shots;
};
Shot.h
#pragma once
#include "VGCVirtualGameConsole.h"
#include "ShootManager.h"
using namespace std;
class Shot
{
public:
virtual ~Shot();
virtual void Update() = 0;
void Draw();
void Move();
enum Alignment
{
FRIEND, ENEMY
};
protected:
VGCVector position;
VGCVector speed;
Alignment alignment;
bool Destroyed = false;
};
我得到这些错误
Error 3 error C2059: syntax error : '>'
Error 7 error C2059: syntax error : '>'
Error 1 error C2061: syntax error : identifier 'Shot'
Error 5 error C2061: syntax error : identifier 'Shot'
Error 2 error C2065: 'Shot' : undeclared identifier
Error 6 error C2065: 'Shot' : undeclared identifier
Error 4 error C2976: 'std::vector' : too few template arguments
Error 8 error C2976: 'std::vector' : too few template arguments
标识错误是此行
void Fire(Shot* shot);
休息了
vector<Shot*> shots;
这两条线路均相当长的一段时间完美的工作,我真的不知道是什么原因导致它突然开始做这些错误。 我还没有开始尝试填充矢量,并没有任何功能被称为尚未。
只需在ShotManager.h中放入'class Shot;'而不是包含Shot.h. – kfsone
@kfsone:你不能从一个不完整的类型中创建一个std :: vector,所以这不会有帮助。 – rici
他有'矢量'而不是'矢量' –
kfsone