分三个文件
//student.h
#ifndef _student_h_
#define _student_h_
class Student{
private:
char name[20];
char no[20];
float score;
public:
Student(char *name,char* no);
friend void display(Student s);
Student& operator =(float score);
};
#endif
//student.cpp
#include
#include
#include "student.h"
using namespace std;
Student::Student(char *name,char *no){
strcpy(this->name,name);
strcpy(this->no,no);
}
void display(Student s){
cout<<"姓名:"<}
Student& Student::operator =(float score){
this->score=score;
return *this;
}
//main.cpp
#include
#include "student.h"
using namespace std;
int main(){
Student t("ly","123");
t=23.4;
display(t);
}
//我的电脑中文乱码,不要在意
Student类,每