正在加载图片...
第6章类与对象 例6.1(续一) void crect: Setcolor(char *c) strcpy(color,c) void CRect: Setsize(int I, int w) length=l 域运算符(∷)用于指出该函数是 width w 哪一个类的成员函数,用法 类名:函数名(参数表 void CRect: Move(int t, int D) top=t left = I H yoid CRect. Drawo cut<<"矩形左上角坐标为(<le<"<top<"<end cout<"矩形长和宽分别为"< ength<"<Wdth<endl;‖ cout<<"矩形的颜色是"<< color<<endl;例6.1 (续一) void CRect::SetColor(char *c) { strcpy(color, c); } void CRect::SetSize(int l, int w) { length=l; width = w; } void CRect::Move(int t,int l) { top = t; left = l; } void CRect::Draw() { cout << "矩形左上角坐标为(" << left << "," << top << ")" << endl; cout << "矩形长和宽分别为" << length << "," << width << endl; cout << "矩形的颜色是" << color << endl; } 第6章 类与对象 域运算符(::)用于指出该函数是 哪一个类的成员函数,用法: 类名::函数名(参数表)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有