加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – static const std :: vector

发布时间:2020-12-16 10:32:37 所属栏目:百科 来源:网络整理
导读:我正在用Qt写一个图像查看器. 我试图在头文件中执行以下操作: class ImageModel{private: const static std::vectorint mZoomLevels;} 在源文件中: int zooms[] = {1,2,3,4,5,6,7,8,9,10};const std::vectorint mZoomLevels(zooms.begin(),zooms.end());
我正在用Qt写一个图像查看器.
我试图在头文件中执行以下操作:

class ImageModel
{


private:
    const static std::vector<int> mZoomLevels;

}

在源文件中:

int zooms[] = {1,2,3,4,5,6,7,8,9,10};
const std::vector<int> mZoomLevels(zooms.begin(),zooms.end());

但是我收到以下错误:

request for member ‘begin’ in zooms which is of non-class type ‘int[10]’
request for member ‘end’ in zooms which is of non-class type ‘int[10]’

有谁知道如何初始化这个静态const私有成员?

解决方法

普通数组没有成员函数.我相信你在寻找这个:

int zooms[] = {1,10};
const std::vector ImageModel::mZoomLevels(zooms,zooms + 10);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读