this is my code snnippet
// test.cpp
#include <iostream>
#include "test.h"
int main(){
  Test<int> test = Test<int>();
  test.add(1);
  test.print();
}
// test.h
#ifndef TEST
#define TEST
template <typename T> class Test{
public:
  T info;
  void print();
  void add(T i);
 };
#endif
// testT.cpp
#include <iostream>
#include "test.h"
template<typename T> void Test<T>::print()
{
   std::cout << info << std::endl;
}
template<typename T> void Test<T>::add(T i)
{
  info = i;
}
and i run this exec
g++ -c testT.cpp && g++ test.cpp -o a.out testT.o
i get this error
Undefined symbols for architecture x86_64:
  "Test<int>::add(int)", referenced from:
      _main in test-e89092.o
  "Test<int>::print()", referenced from:
      _main in test-e89092.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)  // in my macOS
i want to declare template class in head file and define method in other file,so i only compile the define method file not head file if i change the definition of method in template class. what should i do?
 
     
    