友好函数

来源:互联网 发布:网络代理url 编辑:程序博客网 时间:2024/04/29 07:37
 #include <iostream.h>
#include <string.h>
class Student
{
 char name[10];
 double chengj;
public:
 Student(){}
 Student(char n[],double c)
 {
  strcpy(name,n);
  chengj=c;
 }
 friend void number(Student);
};
void number(Student S1)
{
 if(S1.chengj>=80)
  cout<<"姓名:"<<S1.name<<endl;
}
void main()
{
 Student S1("xiaohua",99);
 number(S1);
}
原创粉丝点击