[問題] function 如何傳入或回傳reference NULL

作者: yhn0tgb60 (呦厚厚)   2015-12-14 15:58:22
很多人都會建議 多用 reference 少用 point
可是當function 得回傳值或是 傳入值 是 NULL 時
要如何傳 NULL 的參數給 function 或是 回傳 NULL的reference?
雖然可以 int* aaa=NULL;
int &bbb=*aaa;
但感覺很多此一舉 有更簡便的方式嗎?
感覺 reference 不適合處理 NULL的狀況?
作者: nowar100 (拋磚引玉)   2015-12-14 16:37:00
寫 reference 就是 imply not null 請改用 pointer
作者: uranusjr (←這人是超級笨蛋)   2015-12-14 17:31:00
「多用 reference」正確,「只用 reference」肯定不對

Links booklink

Contact Us: admin [ a t ] ucptt.com