正在加载图片...
10.1。1C++面向对隶的程序实例 2.C++程序实例2 【例102】类的派生。(程序名为1102cpp。) #include <iostream. h> class rectangle ∥定义矩形类 悟言程序设计 ( public void initrect( float len, float wid)∥定义类的成员函数 i length=len width=wid float GetAreaO float Get Perimeter rO private ∥定义私有成员变量 60 float length float width 环 float rectangle: GetAreao ∥成员函数实现 t return length*width;) 返回本节目录【例10.2】类的派生。(程序名为l10_2.cpp。) #include<iostream.h> class rectangle //定义矩形类 { public: void InitRect(float len,float wid) //定义类的成员函数 { length=len; width=wid; } float GetArea(); float GetPerimeter(); private: //定义私有成员变量 float length; float width; }; float rectangle::GetArea() //成员函数实现 { return length*width;} 10.1.1 C++面向对象的程序实例 《 C 语 言 程 序 设 计 》(Visual C++ .6 0 环 境 ) 返回本节目录 2.C++程序实例2
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有