我用vc++6.0编了一个小程序,检查总是出错,请高手解答,本人不胜感激! 程序如下:
#include<iostream>#include<string>usingnamespacestd;classstu{private:intnum;charsex[1...
#include<iostream>
#include<string>
using namespace std;
class stu
{private:
int num;
char sex[10];
string name;
public:
stu()
{num=0000;
name="aaa";
sex="male";
}
void set();
void show();
};
void stu::set()
{cin>>num;
cin>>name;
cin>>sex;
}
void stu::show()
{cout<<num<<" "<<name<<" "<<sex<<endl;}
int main();
{
stu student1,student2;
student1.show();
student2.show();
student.1set();
student2.set();
student1.show();
student2.show();
return 0;
} 展开
#include<string>
using namespace std;
class stu
{private:
int num;
char sex[10];
string name;
public:
stu()
{num=0000;
name="aaa";
sex="male";
}
void set();
void show();
};
void stu::set()
{cin>>num;
cin>>name;
cin>>sex;
}
void stu::show()
{cout<<num<<" "<<name<<" "<<sex<<endl;}
int main();
{
stu student1,student2;
student1.show();
student2.show();
student.1set();
student2.set();
student1.show();
student2.show();
return 0;
} 展开
1个回答
展开全部
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
class stu
{private:
int num;
char sex[10];
string name;
public:
stu()
{num=0;
name="aaa";
strcpy(sex,"male");
}
void set();
void show();
};
void stu::set()
{cin>>num;
cin>>name;
cin>>sex;
}
void stu::show()
{cout<<num<<" "<<name<<" "<<sex<<endl;}
int main()
{
stu student1,student2;
student1.show();
student2.show();
student1.set();
student2.set();
student1.show();
student2.show();
return 0;
}
#include<string>
#include<cstring>
using namespace std;
class stu
{private:
int num;
char sex[10];
string name;
public:
stu()
{num=0;
name="aaa";
strcpy(sex,"male");
}
void set();
void show();
};
void stu::set()
{cin>>num;
cin>>name;
cin>>sex;
}
void stu::show()
{cout<<num<<" "<<name<<" "<<sex<<endl;}
int main()
{
stu student1,student2;
student1.show();
student2.show();
student1.set();
student2.set();
student1.show();
student2.show();
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询