C++ 指针操作vector容器
#include <vector>
#include <stdio.h>
#include <boost/date_time.hpp>
using namespace std;
using namespace boost::gregorian;
const int MAX_SIZE = 1024;
struct Person
{
string strName;
int nAge;
char num[MAX_SIZE] ;
};
typedef struct tagRecord
{
Person m_person;
}Record;
class CTest
{
public:
CTest(void){}
~CTest(){}
Person* GetData()
{
Person *p = & m_stRecord.m_person;
p->nAge = 25;
p->strName = "ganquanfu";
return p;
}
public:
Record m_stRecord;
};
void main()
{
CTest test;
Person *p = test.GetData();
cout << p->strName << " " << p->nAge << endl;
cout << test.m_stRecord.m_person.strName << " " << test.m_stRecord.m_person.nAge << endl;
int wait;
cin >> wait;
}