Suppose I need to have a class which wraps a priority queue of other objects (meaning the queue is a member of the class), and additionally gives it some extra functions.
I am not quite sure what the best way is to define that vector and, mainly, how to instantiate it.
Currently I have something like this in the header file:
// in SomeClass.h: class SomeClass { public: SomeClass(); // constructor // other methods private: std::priority_queue<OtherClass> queue; };
while the source file is something like this:
// in SomeClass.cpp SomeClass::SomeClass(): queue() // removed the constructor, no need to explicitly call it {} // other methods
EDIT: removed the call, per Ray’s answer.
Just write:
C++ knows to call the constructor automatically from there with no arguments.