I have researched this answer on other StackOverflow threads, and I have implemented the advice given in those responses - despite this, the code I have written is still giving me the error of "Symbol(s) not found for architecture x86_64". Any help would be wonderful.
File: DoubleEndedQueue.h
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
class DoubleEndedQueue
{
public:
DoubleEndedQueue();
~DoubleEndedQueue();
void push_back(int element);
int pop_back();
int back();
void push_front(int element);
int pop_front();
int front();
private:
std::vector<int> queue;
};
File: DoubleEndedQueue.cpp
#include <iostream>
#include "DoubleEndedQueue.h"
using namespace std;
DoubleEndedQueue::DoubleEndedQueue() {
//Constructor
vector<int> queue;
}
DoubleEndedQueue::~DoubleEndedQueue() {
//Destructor
}
void DoubleEndedQueue::push_back(int element) {
//Insert element at the back
queue.push_back(element);
}
int DoubleEndedQueue::pop_back() {
//Return and remove element at the back
int elem = queue[queue.size()-1];
queue.erase(queue.begin() + queue.size()-1);
return elem;
}
int DoubleEndedQueue::back() {
//Peek at the element at the back of the queue
return queue[queue.size()-1];
}
void DoubleEndedQueue::push_front(int element) {
//Insert element at the front
vector<int>::iterator it = queue.begin();
queue.insert(it, element);
}
int DoubleEndedQueue::pop_front() {
//Return and remove element at the front
int elem = queue[0];
queue.erase(queue.begin());
return elem;
}
int DoubleEndedQueue::front() {
//Peek at the element at the front of the queue
return queue[0];
}
Thanks so much!
Aucun commentaire:
Enregistrer un commentaire