I am making my own vector class.
.h:
template<typename T>
class MyVector
{
private:
T *elements;
int elementCount;
public:
MyVector();
MyVector(int size);
void push_back(T value);
void pop_back();
int size();
T at(int index);
bool empty();
void clear();
void swap(MyVector v2);
};
.cpp:
template<typename T>
MyVector<T>::MyVector()
{
elementCount = 0;
elements = new int[elementCount];
elements = (int *) realloc (elements, elementCount * sizeof(int));
}
main.cpp:
#include "MyVector.h"
int main()
{
MyVector<char> myTestVector;
return 0;
}
I am getting an error when trying to simply create a MyVector object, the error is :
MyVector::MyVector(), referenced from: _main in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I originally wrote the class to work with an already specified type, now I need it to work with any given type.
Why am I getting this error? Thanks in advance!