i6lan 分享题目的网站
试一试站内搜索 题目类型:问答题

中国古典四大名著歇后语“孙悟空
因果矩阵的作用是什么?
根据《中华人民共和国消防法》的
2019年的4月15日是我国首
1940年7月26日,( )在

在下面程序横线处填上适当字句,完成类的定义。


class line;

class box

{ private:

int color;

int upx, upy;

int lowx, lowy;

public:

_________

void set_color (int c){color=c;}

void define_box (int x1, int y1, int x2, int y2)

{upx=x1;upy=y1;lowx=x2;lowy=y2;}

};

class line

{ private:

int color;

int startx, starty;

int endx, endy;

public:

friend int same_color(line l,box b);

void set_color (int c) {color=c;}

void define_line (___________)

{startx=x1;starty=y1;endx=x2;endy=y2;}

};

int same_color(line l, box b)

{if (l.color==b.color) return 1;

return 0;

}


答案:friend int same_color(line l, box b );,int x1, int y1, int x2, int y2

[解析]成员函数作为友元函数的使用。使用friend关键字。由函数体可知形参的类型和个数。

上一题 下一题

CopyRight©i6lan.com 关于本站
蜀ICP备2021017061号-1

川公网安备 51010402001278号