Dén*_*agy 4 c++ templates typedef vector
我正在尝试向我的类中添加一些typedef,但编译器会在以下代码中报告语法错误:
template<class T>
class MyClass{
typedef std::vector<T> storageType; //this is fine
typedef storageType::iterator iterator; //the error is here
Run Code Online (Sandbox Code Playgroud)
但下一个也不起作用:
typedef std::vector<T>::iterator iterator;
Run Code Online (Sandbox Code Playgroud)
我在很多论坛上寻找答案,但我找不到解决方案或解决方法.谢谢您的帮助!
你错过了一个typename:
typedef typename std::vector<T>::iterator iterator;
Run Code Online (Sandbox Code Playgroud)
有很多类似的问题.例如,看看以下内容:
| 归档时间: |
|
| 查看次数: |
11053 次 |
| 最近记录: |