我在类中编写了一个简单的对象数组程序。谁能告诉我我做错了什么
#include<iostream>
#include<iomanip>
using namespace std;
class employee
{
int name;
public:
void getdata(void);
void putdata(void);
};
void employee :: getdata(void)
{
cout<<"enter name:";
cin>>name;
}
void employee :: putdata(void)
{
cout<<"Name:"<<name<<endl;
}
int main()
{ int i;
employee manager[4];
for(i=0;i<3;i++)
{
manager[i].getdata();
}
for(i=0;i<3;i++)
{
manager[i].putdata();
}
return 0;
}
输出:
enter name:naveen
enter name:enter name:Name:0
Name:0
Name:134515033
naveen@naveen-Ex