64,517
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include "A.h"
using namespace std;
template <typename Type>
class A
{
class B
{
Type data;
};
B b;
public:
void init(const Type & t);
};
template <typename Type>
void A<Type>::init(const Type & t)
{
cout << "hi" << endl;
}
int main()
{
A<int> a;
a.init(7);
return 0;
}
// Everything is ok.
#include <iostream>
using namespace std;
template <typename Type>
class A
{
class B
{
Type data;
};
B b;
public:
void init(const Type & t);
};
#include "A.h"
template <typename Type>
void A<Type>::init(const Type & t)
{
cout << "hi" << endl;
};
#include <iostream>
#include "A.h"
using namespace std;
int main()
{
A<int> a;
a.init(7); // error here. If remove this line, no error.
return 0;
}