三、程序填空题
2.下面的程序输出3,5,请将程序补充完整。
#include <iostream> using namespace std; class point { private: float x, y; public: void f1(float a, float b) { x = a; y = b; } point() { x = 0; y = 0; } void getx() { cout << x << endl; } void gety() { cout << y << endl; } //________________________第一个空 答案:friend void print(point a); }; void print(point a) { cout << a.x << "," << a.y << endl; } int main() { point a; a.f1(3.0, 5.0); //______________第二个空 答案:print(a); return 0; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。