- 32
- 0
- 约7.22千字
- 约 20页
- 2019-04-17 发布于广东
- 举报
《面向对象程序设计》实验报告
姓名
龚剑
学号 1567111128
班级
计 16-1
实验■低十看期-…月22日
项目号、实验名称
实验6静态成员和友元
实验要求(ft课教师提陽
一、 实验目的
1.理解静态成员(静态数据成员、静态成员函数)的作用与使用;
2?理解友元(友元函数、友元类)的作用于使用。
二、 实验内容
2.1 练习(一):
1.理解下面的程序,并在VC++6.0下运行查看结果,冋答程序后面的问题。
#include iostream.h
#include string.h
class CStudent
{
public:
CStudent(char int a);
?CStudent();
static void SetAge(int age);
private:
char *name;
int age;
static int nTotalObj;
};
int CStudent::nTotalObj = 0;
CStudent::CStudent(char int a)
:age(a)
{
int nLen = strlen(n);
name = new char[nLen+l];
strcpy(name,n);
name[nLen] = \0;
nTotalObj++;
}
CStudent:CStudent()
{
delete[] name;
nTot
原创力文档

文档评论(0)