- 论坛徽章:
- 0
|
不知道你是不是这个意思? 随便写了个.
Test.h
- #ifndef TestStruct_Test_h
- #define TestStruct_Test_h
- #include <vector>
- using namespace std;
- struct Fact_t{
- int a;
- int b;
- };
- #endif
复制代码 main.cpp- #include <iostream>
- #include <iterator>
- #include <stdio.h>
- #include "Test.h"
- int main(int argc, const char * argv[])
- {
- Fact_t a1;
- a1.a = 5;
- a1.b = 6;
-
- Fact_t b1;
- b1.a = 15;
- b1.b = 16;
-
- Fact_t c1;
- c1.a = 25;
- c1.b = 26;
- vector<Fact_t> FactV;
- FactV.push_back(a1);
- FactV.push_back(b1);
- FactV.push_back(c1);
-
- vector<Fact_t>::iterator it;
- for (it = FactV.begin(); it != FactV.end(); ++it) {
- printf("a: %d\n", it->a);
- printf("b: %d\n", it->b);
- }
- // insert code here...
- std::cout << "Hello, World!\n";
- return 0;
- }
复制代码 输出
a: 5
b: 6
a: 15
b: 16
a: 25
b: 26 |
|