I'm new at C++. I'm trying to re-implement the container vector. So far I have had a header file named vector.hpp:
#ifndef VECTOR_HPP
#define VECTOR_HPP
#include <iostream>
namespace ft
{
template <typename T>
class vector
{
public:
vector(void);
~vector(void);
private:
unsigned int _size;
};
}
#endif
And a source file named vector.cpp
#include "vector.hpp"
template <typename T>
ft::vector<T>::vector(void): _size(0)
{ std::cout << "Constructor called\n";}
template <typename T>
ft::vector<T>::~vector(void)
{ std::cout << "Deconstructor called\n";}
Then my main.cpp
#include <iostream>
#include "vector.hpp"
int main(void)
{
ft::vector<int> vect_int;
return(0);
}
Then I compile with: c++ main.cpp vector.cpp and it gives the error which I don't know why. Thanks for your help!
/tmp/ccVgRWqs.o: In function `main':
main.cpp:(.text+0x20): undefined reference to `ft::vector<int>::vector()'
main.cpp:(.text+0x31): undefined reference to `ft::vector<int>::~vector()'
collect2: error: ld returned 1 exit status