在矢量问题中排列数据 [英] Arrange data in vector issue

查看:25
本文介绍了在矢量问题中排列数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

class CAnalizeTime {

private:

    vector<CService> m_vData( string m_strSellers );

    sort(m_vData.begin(), m_vData.end());


};

CService 是我创建的另一个类,它包含字符串 m_strSellers

CService is another class that I created and it holds the string m_strSellers

我必须创建一个矢量并由卖家安排

I have to create a vector and arrange it by sellers

我得到的错误是这个 syntax error : identifier 'm_vData'

推荐答案

这一行:

vector<CService> m_vData( string m_strSellers );

试图声明一个成员变量是错误的.只需这样做:

Is a wrong attempt to declare a member variable. Just do this:

vector<CService> m_vData;

另外,声明:

sort(m_vData.begin(), m_vData.end());

不能像那样粗暴地放在类定义中.这是一个语句,必须是函数的一部分.例如:

Cannot be violently put in a class definition just like that. This is a statement that must be part of a function. For instance:

class CAnalizeTime {

    // ...

    void sort_my_vector() 
    { 
        sort(m_vData.begin(), m_vData.end()); 
    }

    vector<CService> m_vData;
};

我不确定您在原始类定义中的意图,但您绝对应该从那里删除该语句并将其放在适当的地方.

I am not sure what you meant to do in your original class definition, but you should definitely remove that statement from there and put it somewhere appropriate.

这篇关于在矢量问题中排列数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆