我有一个由引用传递的另一个对象构造的对象。传递给构造函数的对象如下所示:
HTTPServerResponse::HTTPServerResponse(Poco::Net::HTTPServerResponse &response)
我的包装类 ( HTTPServerResponse
)response
在某些时候会破坏,但它不会自行破坏。response
实际上,即使在我的课堂之外,也有多种(外部)原因可能会被破坏。
我想要的是在调用任何其他方法response
检查它的存在之前。
我试过了:
if(!response) {...
哪个产生了error C2675: unary '!' : 'Poco::Net::HTTPServerResponse' does not define this operator or a conversion to a type acceptable to the predefined operator
;当然,我也尝试过:
if(response) {...
这也失败了error C2451: conditional expression of type 'Poco::Net::HTTPServerResponse' is illegal; No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
我该如何解决这个烂摊子?