我有这个构造函数:
BaseState::BaseState(const BaseState& s) {
id = s.id;
acceptance = s.acceptance;
}
和这个重载的运算符
BaseState& BaseState::operator=(const BaseState& s) {
acceptance = s.acceptance;
id = s.id;
return *this;
}
所以我的问题如下:创建一个像
//primary is a BaseState defined previously
BaseState* temp = new BaseState(primary);
或者
BaseState* temp = primary;
应该是一样的,还是有什么区别?
编辑:primary
是一个指针我也有这个构造函数:
BaseState::BaseState(Id v) {
id = v;
acceptance = false;
}
我创建了我的实例primary
,例如BaseState* primary = new BaseState(0)
.