|
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
struct dates_t {
int p;
int e;
int i;
int d;
};
//Biorhythms
vector <dates_t> get_input(void)
{
vector <dates_t> dates;
dates_t date_item;
int p,e,i,d;
do{
cin >> p >> e >> i >>d ;
if (p == -1 && e== -1 && i == -1 && d == -1)
return dates;
date_item.d = d;
date_item.e = e;
date_item.i = i;
date_item.p = p;
dates.push_back(date_item);
}while(1);
}
int main()
{
vector <dates_t> something;
something = get_input();
for (vector <dates_t>::iterator it = something.begin() ; it < something.end() ; it++) {
cout << (*it).d<< (*it).e << (*it).i << (*it).p << endl;
}
return 0;
}
这个是我写的一个小程序,问题是
vector <dates_t> dates;好象是局部变量,为什么在主函数下可以显示出来? |
|