我是靠谱客的博主 缥缈皮皮虾,这篇文章主要介绍第三章 第8题,现在分享给大家,希望可以做个参考。

#include "iostream"
using namespace std;
class Student
{
private:
int num;
float score;
public:
Student(int ,float);
void change(int,float);
void display();
friend void fun(Student&);
};
Student::Student(int n,float s)
:num(n),score(s)
{}
void Student::change(int n,float s)
{
num=n;
score=s;
}
void Student::display()
{
cout<<num<<" "<<score<<endl;
}
void fun(Student& p)
{
int n;
float s;
cin>>n>>s;
p.change(n,s);
p.display();
}
int main(int argc, char const *argv[])
{
Student stud(101,78.5);
stud.display();
fun(stud);
return 0;
}

最后

以上就是缥缈皮皮虾最近收集整理的关于第三章 第8题的全部内容,更多相关第三章内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(125)

评论列表共有 0 条评论

立即
投稿
返回
顶部