对于非模板类,我可以在头文件中使用前向声明.但是当我在模板类中使用它时,它给了我错误.
我必须包含头文件,我想知道原因.
class Pu;
template <typename T>
class Pt()
{
void test(Pu<T> u);
}
Run Code Online (Sandbox Code Playgroud)
它工作正常,如果你做得好!
请记住,Pu是一个类模板,而不是一个类,所以它必须声明为:
template <typename T> // N.B. this line
class Pu;
template <typename T>
class Pt // N.B. no "()"
{
void test(Pu<T> u);
}; // N.B. ";"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
112 次 |
| 最近记录: |