I get two heads: header1:
#ifndef CPPSH_A_H
#define CPPSH_A_H
class B;
class A {
public:
template<typename T>
void Function1() {
b_->Function2<int>();
}
template<typename T>
void Function2() {
}
private:
B* b_;
};
#endif //CPPSH_A_H
and header2:
#ifndef CPPSH_B_H
#define CPPSH_B_H
class A;
class B {
public:
template<typename T>
void Function1() {
a_->Function2<int>();
}
template<typename T>
void Function2() {
}
private:
A* a_;
};
#endif //CPPSH_B_H
and you can see that both a_ and b_ is incomplete type, and the calls on it is invaild.
if these two classes are normal classes, I can move the Test() implementation to source file, and then include the proper header.
But since template classes/functions must define and declare their implementation in headers, how to deal this problem?