[英]How to know an object address in a method?
例如,我有這個課:
class example{
public:
int beauty;
void CompareObject(const example& another_object, example*& ptr);
};
方法CompareObject()將此對象與對象another_object比較(通過引用),並將最漂亮的對象的地址保存在指針ptr中(也通過引用傳遞)
問題在CompareExampleObject中:
void CompareExampleObject (const example& another_object, example*& ptr){
// set the best object
if(beauty < another_object.beauty)
ptr = &another_object;
else
ptr = // !!! What should I write here?
}
this
是對象方法內部的對象地址。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.