[问题] 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