首页IT科技look at all the flags翻译(A Quick Look at References and Constants)

look at all the flags翻译(A Quick Look at References and Constants)

时间2025-06-15 12:42:14分类IT科技浏览4402
导读:References and Constants Table of Contents What is a reference? A class object (i.e. not a built-in object may be returned by reference or p...

References and Constants

Table of Contents What is a reference? A class object (i.e. not a built-in object) may be returned by reference or passed by reference for better efficiency. When used properly, returning by reference allows the function to appear on the left-hand side of an expression. Passing/returning by reference allows the referenced object to be modified. If the intention of the class designer is to avoid modification of the passed/returned object, the reference should be made const. If a member function will not modify its data members, make the member function const. It is illegal to modify any object or reference that is declared const. Therefore, constant objects and references may only call constant member functions. What is a reference?

A reference is nothing more than an alias. Anything

you do with a

reference you are actually doing to the object you are referencing. float x=3.14; float& intref=x; // intref is a reference to x float* ptr=&intref; // ptr holds the address of x float y=2.58; intref=y; // x is now equal to 2.58

创心域SEO版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

展开全文READ MORE
看视频新闻赚钱软件排行榜(看新闻视频给钱的软件叫什么-剪辑视频赚钱的软件有哪些?账号数据怎么查看?) cookie,session,localstorage区别(cookie 、sessionstorage 、localstorage三者的区别)