There was a problem when writing a template class, in its test method a method of another class is called, I get an error when compiling
undefined reference to `bar :: printHello () '
What could be the problem?
main.cpp
#include<main.h> #include <foo.h> int main(){ foo<int> _fo ; _fo.test(); return 0; } main.h
#pragma once #include <bar.h> foo.h
#pragma once #include<bar.h> template<class T> class foo{ public: foo(){ } void test(){ bar b; b.printHello(); } }; foo.cpp
#include "foo.h" bar.h
#pragma once class bar { public: bar(); void printHello(); }; bar.cpp
#include "bar.h" #include <iostream> bar::bar() { } void printHello(){ std::cout<<"Hello"; }