正在加载图片...
10.1.1C++面向对象的程序实例 float rectangle: GetAreao ∥)员函数的具体实现 i return length*width float rectangle: GetPerimeterO ∥)员函数的具体实现 翟{ return 2*(length+width); 序设 void maino 计{ float l, w: cou<"请输入矩形的长和宽"; cin>>1>>w: rectangle x(l, w) ∥定义一个矩形类对象 60 cout<<x. GetArea(<<endl cout<< x Get Perimeter(<<endl;∥调用成员函数 环 境 返回本节目录float rectangle::GetArea() //成员函数的具体实现 { return length*width; } float rectangle::GetPerimeter() //成员函数的具体实现 { return 2*(length+width); } void main() { float l,w; cout<<"请输入矩形的长和宽:"; cin>>l>>w; rectangle x(l,w); //定义一个矩形类对象 cout<<x.GetArea()<<endl; cout<<x.GetPerimeter()<<endl; //调用成员函数 } 10.1.1 C++面向对象的程序实例 《 C 语 言 程 序 设 计 》(Visual C++ .6 0 环 境 ) 返回本节目录
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有