这两个构造函数声明有什么区别:
class Fruit {
private:
int price;
public:
Fruit(int x): price(x)
{
}
};
VS
class Fruit {
private:
int price;
public:
Fruit(int x)
{
price = x;
}
};
我在继承的情况下看到的第一个。
据我所知,这不是一个重复的问题。如果你发现有人可以关闭这个问题。