class Stone {
public:
Stone(int w, int h, int weight) :m_w(w), m_h(h), m_weight(weight) {
//这种初始化方法需要知道
}
//等价于
Stone(int w, int h, int weight) {
m_w = w;
m_h = h;
m_weight = weight;
}
private:
int m_w, m_h, m_weight;
};
C++中一种方便的初始化方式
于 2022-10-17 18:27:04 首次发布