新手求助,用两个类写一个员工信息统计。
#include<iostream>using namespace std;
enum paople_sex{m,f};
class birthday
{
private:
int year;
int month;
int day;
public:
void birth()
{
cout<<"the birthday"<<endl;
cout<<"please input the year:";
cin>>year;
cout<<"please input the month:";
cin>>month;
cout<<"please input the day:";
cin>>day;
}
void print2()
{
cout<<year<<"."<<month<<"."<<day<<endl;
}
};
class people
{
private:
long int number;
char sex;
long int id;
public:
void xinxi()
{
birthday b;
cout<<"please input the number:";
cin>>number;
cout<<"please input the sex:(m/f)";
cin>>sex;
cout<<"please input the id:";
cin>>id;
b.birth();
}
void print1()
{
birthday b;
cout<<number<<endl
<<sex<<endl
<<id<<endl;
b.print2();
}
};
void main()
{
int i,n;
system("color 9e");
people p[1000];
cout<<"How many people?";
cin>>n;
for(i=0;i<n;i++)
{
p[i].xinxi();
}
for(i=0;i<n;i++)
{
p[i].print1();
}
}
为什么最后出来year.month.day为未赋值