- 论坛徽章:
- 0
|
// testVector.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>
using namespace std;
typedef struct test
{
int a;
int b;
};
typedef struct test1
{
int a1;
int b1;
}test1;
int main(int argc, char* argv[])
{
vector<test*> _test;
test1 test2[2] = {{100,2},{200,3}};
test* newTest1;
newTest1 = new test;
test* newTest2;
newTest2 = new test;
//newTest1 = &test2[0];
//newTest2 = &test2[1];
memcpy( (char*)newTest1, (char*)&test2[0], sizeof(test) );
memcpy((char*)newTest2, (char*)&(test2[1]), sizeof(test) );
int i;
for(i=0;i<2;i++)
{
//_test.push_back(test2[i]);
}
_test.push_back(newTest1);
_test.push_back(newTest2);
for(i=0;i<2;i++)
{
cout << _test[i]->a<<endl;
cout << _test[i]->b<<endl;
}
cin >> i;
return 0;
} |
|