C++高手进来拿分 追加100

来源:百度知道 编辑:UC知道 时间:2024/06/04 03:41:53
2. 标准输入流中输入一串任意字符,把其中的数字反排序输出。不使用库函数。

3. 建立一个文本文件student.txt,保存在自己的目录下备用。文件中内容为如下几行: Name=Zhangsan
Age=32
Address=Zhangjiagang, Jiangsu
Score=90
建立一个头文件student.h,保存在自己的目录下备用。文件内容为student类的声明:
#include <iostream>
#include <fstream>
#include <list>
#include <string>
using namespace std;
class student
{
private:
string name;
unsigned int age;
string address;
float score;
public:
student( ){ }; //无参构造函数,不做任何操作
student(string file_name);//从文件中读取信息初始化各个数据成员
friend ostream& operator<<(ostream& os, const student& stu);//用于向标准输出设备输出student类对象的内容
friend istream& operator>>(istream& is, student& stu); //用于从标准输入设备读取信息到student类对象中
friend bool operator<(const student& s1, const student& s2); //用于按年龄比较两个student类对象第一个是否小于第二个
};
1、建立一个实现文件student.cpp,实现student类中声明的带参构造函数用来从指定文件中读取信息到一个student对象中,重载输出运算符(<<)用来把一个stud

我来回答: 嘿嘿

1:C++

2. 标准输入流中输入一串任意字符,把其中的数字反排序输出。不使用库函数。

3. 建立一个文本文件student.txt,保存在自己的目录下备用。文件中内容为如下几行: Name=Zhangsan
Age=32
Address=Zhangjiagang, Jiangsu
Score=90
建立一个头文件student.h,保存在自己的目录下备用。文件内容为student类的声明:
#include <iostream>
#include <fstream>
#include <list>
#include <string>
using namespace std;
class student
{
private:
string name;
unsigned int age;
string address;
float score;
public:
student( ){ }; //无参构造函数,不做任何操作
student(string file_name);//从文件中读取信息初始化各个数据成员
friend ostream& operator<<(ostream& os, const student& stu);//用于向标准输出设备输出student类对象的内容
friend istream& operator>>(istream& is, student& stu); //用于从标准输入设备读取信息到student类对象中
friend bool operator<(const student& s1, const student& s2); //用于按年龄比较两个student类对象第一个是否小于第二个
};
1、建立一个实现文件student.cpp,实现student类中声明的带参构造函数用