/*1. 定义一个学生类,其中有3个数据成员有学号、姓名、年龄,以及若干成员函数。同时编写主函数使用这个
要求:使用成员函数实现对数据的输入、输出使用构造函数和析构函数实现对数据的输入、输出。*/下面有个程序,请高手改一下(错误太多,多多包涵)#include<iostrea...
要求:
使用成员函数实现对数据的输入、输出
使用构造函数和析构函数实现对数据的输入、输出。 */
下面有个程序,请高手改一下(错误太多,多多包涵)
#include<iostream>
using namespace std;
class student{
private:
int xuehao;
char xingming[20];
int nianling;
public:
student(int XUEHAO,char XINGMING[20],int NIANLING)
{
XUEHAO=xuehao,XINGMING[20]=xingming,NIANLING=nianling;
cout<<"学号:"<<XUEHAO<<"姓名:"<<XINGMING[]<<"年龄:"<<NIANLING<<endl;
}
~student()
{
cout<<学号:<<XUEHAO<<姓名:<<XINGMING[]<<年龄:<<NIANLING<<endl;
}
};
main()
{
student s1(1542,jializhu,54);
student s2(2553,jialiniu,65);
student s3(2154,jialigou,48);
return 0;
} 展开
使用成员函数实现对数据的输入、输出
使用构造函数和析构函数实现对数据的输入、输出。 */
下面有个程序,请高手改一下(错误太多,多多包涵)
#include<iostream>
using namespace std;
class student{
private:
int xuehao;
char xingming[20];
int nianling;
public:
student(int XUEHAO,char XINGMING[20],int NIANLING)
{
XUEHAO=xuehao,XINGMING[20]=xingming,NIANLING=nianling;
cout<<"学号:"<<XUEHAO<<"姓名:"<<XINGMING[]<<"年龄:"<<NIANLING<<endl;
}
~student()
{
cout<<学号:<<XUEHAO<<姓名:<<XINGMING[]<<年龄:<<NIANLING<<endl;
}
};
main()
{
student s1(1542,jializhu,54);
student s2(2553,jialiniu,65);
student s3(2154,jialigou,48);
return 0;
} 展开
展开全部
#include<iostream>
#include<string>
using namespace std;
class student{
private:
int xuehao;
string xingming;
int nianling;
public:
student(int XUEHAO,string XINGMING,int NIANLING)
{
xuehao=XUEHAO;xingming=XINGMING;nianling=NIANLING;
cout<<"学号:"<<xuehao<<"姓名:"<<xingming<<"年龄:"<<nianling<<endl;
}
~student()
{
cout<<"学号:"<<xuehao<<"姓名:"<<xingming<<"年龄:"<<nianling<<endl;
}
};
int main()
{
student s1(1542,"jializhu",54);
student s2(2553,"jialiniu",65);
student s3(2154,"jialigou",48);
return 0;
}
#include<string>
using namespace std;
class student{
private:
int xuehao;
string xingming;
int nianling;
public:
student(int XUEHAO,string XINGMING,int NIANLING)
{
xuehao=XUEHAO;xingming=XINGMING;nianling=NIANLING;
cout<<"学号:"<<xuehao<<"姓名:"<<xingming<<"年龄:"<<nianling<<endl;
}
~student()
{
cout<<"学号:"<<xuehao<<"姓名:"<<xingming<<"年龄:"<<nianling<<endl;
}
};
int main()
{
student s1(1542,"jializhu",54);
student s2(2553,"jialiniu",65);
student s3(2154,"jialigou",48);
return 0;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询