正在加载图片...
面向对象程序设计 例2:文件 student. cpp #include<iostream. h include" student. h"∥必须包含类的定义 void student: input(int n, char *na, float s) number-n 堂提要 score=s name=new char[ strlen(na)+1] 第6章类与对象 strcpy(name, na);) 6.1类定义与对象声明 62对象的使用 void student: modify (float s)score=S;) 63对象成员 64友员 friend void student: display() 6.5静态成员和对象组 cout 织 n number number cout <<"n name. < name 6.6模板 6.7应用举例 cout <<" In score: < score第 6章 类与对象 6.1 类定义与对象声明 6.2 对象的使用 6.3 对象成员 6.4 友员 friend 6.5 静态成员和对象组 织 6.6 模板 6.7 应用举例 例2:文件 student.cpp #include<iostream.h> #include "student.h" //必须包含类的定义 void student::input(int n, char *na, float s) { number=n; score=s; name=new char[strlen(na) + 1]; strcpy(name, na); } void student::modify(float s) {score=s;} void student::display( ) { cout << "\n number: "<< number; cout << "\n name:"<< name; cout << "\n score: "<< score; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有