main.cpp
#include <my_func.hpp>
using namespace std;
int main()
{
MyClass my_class;
my_class.func("123");
}
my_func.hpp
#include <iostream>
class MyClass{
void func(auto value);
}
my_func.cpp
#include <my_func.hpp>
void MyClass::func(auto value){
cout << value << endl;
}
the error occured "undefined reference to function"
but when I write code like this my_func.hpp
#include <iostream>
class MyClass{
void func(auto value);
}
void MyClass::func(auto value){
cout << value << endl;
}
It works very well.
I want to divide definition and source. but I dont know how to solve the problem.
I think that cause is "auto". when I change auto to string, It works well. but I have to get multi type parameter and I dont want to overloading because of the code is all same.
help me please.