码迷,mamicode.com
首页 > 编程语言 > 详细

c++ vector struct 使用

时间:2015-04-08 09:07:57      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

 

 

1.

//test.h
#include <string>
using namespace  std;
struct AA
{
    string a1;
    string a2;
    string a3;
};



class test
{
public:
    void ReadString(vector<AA> vv);

};
#include "StdAfx.h"
#include "test.h"

void test::ReadString(vector<AA> vv)
{
    vector<AA>::iterator it;
    for (it=vv.begin();it!=vv.end();++it)
    {
        string ss=it->a1;
    }
        
}
void CtttttttDlg::OnBnClickedButton1()
{
    // TODO: Add your control notification handler code here

 
   AA aa1;
   aa1.a1="aaaa11";
   aa1.a2="aaaa12";
   aa1.a3="aaa13";


   AA aa2;
   aa2.a1="aaaa21";
   aa2.a2="aaaa22";
   aa2.a3="aaa23";

   vector<AA> vv;
   vv.push_back(aa1);
   vv.push_back(aa2);

   /*vector<AA>::iterator it;
   for (it=vv.begin();it!=vv.end();++it)
   {
       string ss=it->a1;
   }
  */

   test ts;
   ts.ReadString(vv);

}

 

c++ vector struct 使用

标签:

原文地址:http://www.cnblogs.com/ike_li/p/4401409.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!