【问题标题】:Error 2 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int Vector Template错误 2 错误 C4430:缺少类型说明符 - 假定为 int。注意:C++ 不支持默认整数向量模板
【发布时间】:2014-08-06 16:55:09
【问题描述】:

我被告知要以某种方式完成这项任务。默认情况下为bitarray制作一个unsigned int模板,并且向量保存它,但现在我收到错误C4430。

#include <vector>


template<class IType = unsigned int>
class BitArray {
private:
    size_t numbits;
    size_t capacity;
    vector<IType>  bits;
}

【问题讨论】:

  • std::vector 之前丢失??你在哪里使用这个类?
  • 你还应该有#include &lt;cstdlib&gt;std::size_t

标签: c++ templates vector


【解决方案1】:

你必须写

std::vector<IType>  bits;

【讨论】:

    【解决方案2】:
    template<class IType = unsigned int>
    class BitArray {
    private:
        size_t numbits;
        size_t capacity;
        std::vector<IType>  bits; // <- add std:: before vector
    }; // <- you must add a semicolon
    

    【讨论】:

      猜你喜欢
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 2013-09-17
      • 2017-03-28
      • 1970-01-01
      • 2022-12-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多