我的程序能运行但是有乱码,请大虾帮助看一下,在下不胜感激,谢谢!
#include <cstring>
#include<iostream>
using namespace std;
class Employee{
private:char name[10];
char address[20];
char city[15];
char stampno[6];
public:void change_name(char str[10]);
void display();
void Setname(char *namestr);
void Setaddress(char *addr);
void Setcity(char *cty);
void Setstampno(char *no);
};
void Employee::Setname(char *namestr)
{strcpy(name,namestr);}
void Employee::Setaddress(char *addr)
{strcpy(address,addr);}
void Employee::Setcity(char *cty)
{strcpy(city,cty);}
void Employee::Setstampno(char *no)
{strcpy(stampno,no);}
void Employee::change_name (char *str)
{ strcpy(name,str);}
void Employee::display()
{cout<<"name:"<<name<<endl<<"address:"<<address<<endl<<"city:"<<city<<endl<<"stampno:"<<stampno<<endl;}
void main()
{ char namestr[10],addr[20],cty[15],str[10],no[6] ;
Employee employee;
cout<<"please enter employeer's name :"<<endl;
cin>>namestr[10];
employee.Setname(namestr);
cout<<"please enter employeer's address:"<<endl;
cin>>addr[20];
employee.Setaddress(addr);
cout<<"please enter employeer's city:"<<endl;
cin>>cty[15] ;
employee.Setcity(cty);
cout<<"please enter employeer's stampno:"<<endl;
cin>>no;
employee.Setstampno(no);
employee.display();
cout<<"please enter your new name :"<<endl;
cin>>str;
employee.change_name(str);
employee.display();
}