例如,我有这样一个类:
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?
}https://stackoverflow.com/questions/41407913
复制相似问题