#include <iostream>
using namespace std;
template <class T>
class SimNode
{
friend SimSpace<T>;
private:
T data;
int link;
};
template <class T>
class SimSpace
{
private:
SimNode<T>* space;
};
int main()
{
system("pause");
return 0;
}
报错之后问题出现在
friend SimSpace<T>;
请问为什么?
PHP中文网2017-04-17 13:01:50
There is something wrong with your statement, it should be
class SimNode
{
private:
template <class T> //声明不要漏了template <class T>,这是C++很蛋疼的一个地方
friend class SimSpace;
T data;
int link;
};