I'm trying to create a new object of the class Queue<T>
, with the following:
Queue<char[40]> *q = new Queue<char[40]>(100);
Then, I want to use this q
on another class constructor:
Interface<char[40]> i(q);
If I just use it, I get an error saying invalid conversion from ‘Queue<char [40]>*’ to ‘int’
, which I figure means I'm trying to pass the value of q, which is the pointer to it instead of the actual value. Fine. Then I redefined the Interface<T>
constructor to receive a pointer instead of the value itself, so the signature is
Interface(DataStructure<T>& q);
Since Queue extends DataStructure. For some reason, now the instantiation of q
fails:
undefined reference to `Queue<char [40]>::Queue(int)
But I am quite sure I have written the constructor method WITH an INT parameter
template<typename T>
Queue<T>::Queue(int size): DataStructure<T>(size) {
std::cout << size << std::endl;
}
Why the hell am I getting this error, then? To play with pointers is just getting a mess and I could not figure out by any means what to do now.