【发布时间】:2019-12-06 00:47:07
【问题描述】:
我不确定这部分代码的确切用途,我需要在我的研讨会上解释它。
class point {
public:
point( int a = 0, int b = 0 ) **{ x = a; y = b; }**
bool operator ==( const point& o ) { return o.x == x && o.y == y; }
point operator +( const point& o ) { return point( o.x + x, o.y + y ); }
int x, y;
};
【问题讨论】:
-
google:什么是 c++ 构造函数
-
它是一个构造函数,它在创建对象时为其赋予初始值。你真的在学习 C++,还没有人告诉你关于构造函数的事吗?
-
这部分是函数体。
标签: c++ class constructor initialization default-constructor