【发布时间】:2016-12-05 08:15:57
【问题描述】:
我正在尝试使用 C++ 进行编程,但遇到以下情况:
template<Class U>;
Class A<U>;
Class B;
我需要执行该代码:
A<A<B>> x;
但我得到了错误:
error: template argument 1 is invalid
warning: >> operator will be treated as two right angle brackets in C++
我也试过了:
A<(A<B>)> x;
但还是不行。我该如何管理?
【问题讨论】:
-
请不要发布虚假代码,而是minimal reproducible example。
-
试试
A<A<B> > x;。 -
@Yaklefak 看来您的编译器不支持 C++11。从 C++11 开始,语法应该没问题。
标签: c++ class templates data-structures