假设我需要一个包装其他对象的优先级队列(意味着队列是该类的成员)的类,并且还给它一些额外的功能。将队列实例化为C++中的类成员
我不太确定最好的方法是定义该向量,主要是如何实例化它。
目前我有在头文件是这样的:
// in SomeClass.h:
class SomeClass
{
public:
SomeClass(); // constructor
// other methods
private:
std::priority_queue<OtherClass> queue;
};
而源文件是这样的:
// in SomeClass.cpp
SomeClass::SomeClass():
queue() // removed the constructor, no need to explicitly call it
{}
// other methods
编辑:删除通话,每雷的回答。
忘记我最后的编辑 - 这很好。谢谢您的帮助。 – 2009-01-31 13:25:26