如何在类中用向量做为成员变量

如何在类中用向量做为成员变量,第1张

//添加vector的头文件即可,下面的代码可以编译通过

#include <vector>

using namespace std

class MPoint

{

public:

int y

int x

vector<double> a

public:

MPoint(int, int)

virtual ~MPoint()

}

void main()

{

return

}

头文件前面添加

#include <vector>

using namespace std

之后就可以正常使用vector了

vector<int>m_vecInts

vector<int>m_vecInts2

m_vecInts.swap(m_vecInts2)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/bake/11610744.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-17
下一篇2023-05-17

发表评论

登录后才能评论

评论列表(0条)

    保存