调用构造函数重新初始化对象

2021-12-30 00:00:00 constructor c++

是否可以使用其构造函数重新初始化类的对象?

is it possible to re-initialize an object of a class using its constructor?

推荐答案

排序.给定一个 A 类:

Sort of. Given a class A:

A a;
...
a = A();   

最后一条语句不是初始化,而是赋值,但它可能会做你想要的.

the last statement is not initialisation, it is assignment, but it probably does what you want.

相关文章