我正试图做两件让我有问题的事情:
1)typedef std::vector
2)声明std::auto_ptr
这两个都给了我错误"invalid use of template-name 'std::vector/auto_ptr' without an argument list"
。这是导致错误的标题:
ResourceLocationDefinition.h
// ResourceLocationDefinition contains the information needed
// by Ogre to load an external resource.
#ifndef RESOURCELOCATIONDEFINITION_H_
#define RESOURCELOCATIONDEFINITION_H_
#include "string"
#include "vector"
struct ResourceLocationDefinition
{
ResourceLocationDefinition(std::string type, std::string location, std::string section) :
type(type),
location(location),
section(section)
{
}
~ResourceLocationDefinition() {}
std::string type;
std::string location;
std::string section;
};
typedef std::vector ResourceLocationDefinitionVector;
#endif
EngineManager.h
#ifndef ENGINEMANAGER_H_
#define ENGINEMANAGER_H_
#include "memory"
#include "string"
#include "map"
#include "OGRE/Ogre.h"
#include "OIS/OIS.h"
#include "ResourceLocationDefinition.h"
// define this to make life a little easier
#define ENGINEMANAGER OgreEngineManager::Instance()
// All OGRE objects are in the Ogre namespace.
using namespace Ogre;
// Manages the OGRE engine.
class OgreEngineManager :
public WindowEventListener,
public FrameListener
{
public:
// Bunch of unrelated stuff to the problem
protected:
// Constructor. Initialises variables.
OgreEngineManager();
// Load resources from config file.
void SetupResources();
// Display config dialog box to prompt for graphics options.
bool Configure();
// Setup input devices.
void SetupInputDevices();
// OGRE Root
std::auto_ptr root;
// Default OGRE Camera
Camera* genericCamera;
// OGRE RenderWIndow
RenderWindow* window;
// Flag indicating if the rendering loop is still running
bool engineManagerRunning;
// Resource locations
ResourceLocationDefinitionVector resourceLocationDefinitionVector;
// OIS Input devices
OIS::InputManager* mInputManager;
OIS::Mouse* mMouse;
OIS::Keyboard* mKeyboard;
};
#endif /* ENGINEMANAGER_H_ */
答案 0 :(得分:4)
使用模板时,您必须为矢量提供模板参数,您可能希望这样做:
typedef std::vector<ResourceLocationDefinition> ResourceLocationDefinitionVector;
表示您的向量引用ResourceLocationDefinition
对象实例。
以及auto_ptr
这样的内容:
std::auto_ptr<Root> root;
我相信你想要一个Ogre::Root
指针吗?
答案 1 :(得分:0)
错误很清楚。 auto_ptr
和vector
是模板。它们要求您指定实际要与它们一起使用的类型。
struct my_type {
int x, y;
};
std::vector<my_type> v; // a vector of my_type
std::vector<int> iv; // a vector of integers
关于auto_ptr
:由于其奇怪的语义,它已被弃用。考虑使用std::unique_ptr
(在您的平台上可用时)或boost::scoped_ptr
(当您具有提升依赖性时。)