gpt4 book ai didi

c++ - 在没有参数列表的情况下无效使用模板名称

转载 作者:行者123 更新时间:2023-11-30 02:02:09 25 4
gpt4 key购买 nike

我正在尝试做两件给我带来问题的事情:

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_ */

最佳答案

当使用模板时,你必须提供模板参数,对于你的 vector ,你可能想做这样的事情:

typedef std::vector<ResourceLocationDefinition> ResourceLocationDefinitionVector;

这意味着您的 vector 引用了 ResourceLocationDefinition 对象实例。

对于你的 auto_ptr 是这样的:

std::auto_ptr<Root> root;

我相信你想要一个 Ogre::Root 指针吧?

关于c++ - 在没有参数列表的情况下无效使用模板名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13536378/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com