Hi I know this seems like a really dumb question and honestly I'm lost on what is causing this object error and could really use some help.
I have this class here :
class PriorityQueue {
public:
PriorityQueue(std::size_t max_nodes);
void insert(Key k);
void insert(KeyValuePair kv);
KeyValuePair min();
KeyValuePair removeMin();
bool isEmpty() const;
size_t size() const;
nlohmann::json JSON() const;
private:
void heapifyUp(size_t i);
void heapifyDown(size_t i);
void removeNode(size_t i);
Key getKey(size_t i);
std::vector<KeyValuePair> nodes_;
size_t max_size_;
size_t size_;
const static size_t ROOT = 1;
}; // class PriorityQueue
#endif // _PRIORITYQUEUE_H_
Everything is properly defined in the corresponding cpp file for it. Now I'm trying to call it in a separate file that includes both as a header.
#include "priorityqueue.cpp"
#include "priorityqueue.h"
But in my main() function when I try to call the class to an object like
PriorityQueue m;
I get the error
no matching function for call to ‘PriorityQueue::PriorityQueue()’
PriorityQueue m;
I know this seems like a really basic C++ question but I have no idea what I am doing wrong. Any help would be greatly appreciated.
#include "priorityqueue.cpp"- This is only going to cause you grief down the line. Get out of the habit. It's better to work with the way C++ is compiled and linked.