#include<iostream> using namespace std; class Student { private: string name; int age; double high;
#include<iostream>usingnamespacestd;classStudent{private:stringname;intage;doublehigh...
#include<iostream>
using namespace std;
class Student
{
private:
string name;
int age;
double high;
char sex;
public:
Student(){};
Student(string n,int a,double h,char s);
void display();
void changage();
void set_data();
};
Student::Student(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::display()
{
cout<<"姓名:"<<name<<'\t'<<"年龄:"<<age<<'\t'<<"身高:"<<high<<'\t';
switch(sex)
{
case 'w':cout<<"男";break;
default:cout<<"女";break;
}
}
void Student::changage(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::set_data()
{
cout<<"请依次输入姓名,年龄,身高,性别:"
cin>>name>>age>>high>>sex>>endl;
}
void main()
{
Student a1,a2;
a1("zhanghua",23,1.56,'w');
a1.display();
a2.set_data();
a2.display();
}
请高手指点迷津!重点是输出函数怎么错了!!! 展开
using namespace std;
class Student
{
private:
string name;
int age;
double high;
char sex;
public:
Student(){};
Student(string n,int a,double h,char s);
void display();
void changage();
void set_data();
};
Student::Student(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::display()
{
cout<<"姓名:"<<name<<'\t'<<"年龄:"<<age<<'\t'<<"身高:"<<high<<'\t';
switch(sex)
{
case 'w':cout<<"男";break;
default:cout<<"女";break;
}
}
void Student::changage(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::set_data()
{
cout<<"请依次输入姓名,年龄,身高,性别:"
cin>>name>>age>>high>>sex>>endl;
}
void main()
{
Student a1,a2;
a1("zhanghua",23,1.56,'w');
a1.display();
a2.set_data();
a2.display();
}
请高手指点迷津!重点是输出函数怎么错了!!! 展开
2个回答
展开全部
#include<iostream>
using namespace std;
class Student
{
private:
string name;
int age;
double high;
char sex;
public:
Student(){};
Student(string n,int a,double h,char s);
void display();
void changage();//这个函数啊,怎么与下面的实现不一样啊,搞什么
void set_data();
};
Student::Student(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::display()
{
cout<<"姓名:"<<name<<'\t'<<"年龄:"<<age<<'\t'<<"身高:"<<high<<'\t';
switch(sex)
{
case 'w':cout<<"男";break;
default:cout<<"女";break;
}
}
void Student::changage(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::set_data()
{
cout<<"请依次输入姓名,年龄,身高,性别:"//上面的cout都有分号,这块怎么没了?
cin>>name>>age>>high>>sex>>endl;//endl是变量?不是的话你想给他传什么?
}
void main()
{
Student a1,a2;
a1("zhanghua",23,1.56,'w');//这句啊,怎么学的c++啊
a1.display();
a2.set_data();
a2.display();
}
//错误提示都不贴,看来是个新手,而且还不会提问
using namespace std;
class Student
{
private:
string name;
int age;
double high;
char sex;
public:
Student(){};
Student(string n,int a,double h,char s);
void display();
void changage();//这个函数啊,怎么与下面的实现不一样啊,搞什么
void set_data();
};
Student::Student(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::display()
{
cout<<"姓名:"<<name<<'\t'<<"年龄:"<<age<<'\t'<<"身高:"<<high<<'\t';
switch(sex)
{
case 'w':cout<<"男";break;
default:cout<<"女";break;
}
}
void Student::changage(string n,int a,double h,char s)
{
name=n;age=a;high=h;sex=s;
}
void Student::set_data()
{
cout<<"请依次输入姓名,年龄,身高,性别:"//上面的cout都有分号,这块怎么没了?
cin>>name>>age>>high>>sex>>endl;//endl是变量?不是的话你想给他传什么?
}
void main()
{
Student a1,a2;
a1("zhanghua",23,1.56,'w');//这句啊,怎么学的c++啊
a1.display();
a2.set_data();
a2.display();
}
//错误提示都不贴,看来是个新手,而且还不会提问
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询