C ++:指针Vs引用 [英] C++: pointers Vs references

查看:95
本文介绍了C ++:指针Vs引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有人可以提供关于指针与引用之间差异的简短陈述(b)。

的图形表示(通过链接?)也将非常受欢迎。

WD


---

发送邮件经过无病毒认证。

由AVG反病毒系统检查( http://www.grisoft.com)

版本:6.0.504 /病毒库:302 - 发布日期:24/07/2003

Hi,

Can someone provide a short and concise statement(s) on the difference
between pointers and references. A graphical representation (via links?) of
both would be much appreciated as well.
WD

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.504 / Virus Database: 302 - Release Date: 24/07/2003

推荐答案

Web Developer< no **** @ hotmail.com>在消息中写道

news:3f ********** @ news.iprimus.com.au ...
Web Developer <no****@hotmail.com> wrote in message
news:3f**********@news.iprimus.com.au...

<有人可以提供关于指针和引用之间差异的简短陈述。


指针是一个对象,包含另一个对象的内存中的地址; a

引用是另一个对象的别名。

指针可以为null;引用不能。

指针可以重新就位(即指向不同的对象); a

引用不能。

当创建

时,必须初始化引用(即指定其引用);指针可以是未初始化的。


的图形表示(通过链接?)也将非常受欢迎。
Hi,

Can someone provide a short and concise statement(s) on the difference
between pointers and references.
A pointer is an object containing the address in memory of another object; a
reference is an alias for another object.
A pointer can be null; a reference cannot.
A pointer can be re-seated (i.e., pointed at a different object); a
reference cannot.
A reference must be initialized (i.e., its refer-ee specified) when it is
created; a pointer can be uninitialized.
A graphical representation (via links?) of
both would be much appreciated as well.




我不确定会是什么样子。无论如何,我无法提供。


DW



I''m not sure what one would look like. Anyway, I am unable to provide one.

DW




" ;大卫怀特 < no@email.provided>在消息中写道

news:ta **************** @ nasal.pacific.net.au ...

"David White" <no@email.provided> wrote in message
news:ta****************@nasal.pacific.net.au...
Web开发者< no **** @ hotmail.com>在消息中写道
新闻:3f ********** @ news.iprimus.com.au ...
Web Developer <no****@hotmail.com> wrote in message
news:3f**********@news.iprimus.com.au...


可以有人提供关于指针和引用之间差异的简短陈述。
指针是包含另一个对象的内存中的地址的对象;
Hi,

Can someone provide a short and concise statement(s) on the difference
between pointers and references.
A pointer is an object containing the address in memory of another object;



a reference是另一个对象的别名。
指针可以为null;引用不能。
指针可以重新就位(即指向不同的对象);
引用不能。
引用必须在创建时初始化(即指定其引用);一个指针可以是未初始化的。


a reference is an alias for another object.
A pointer can be null; a reference cannot.
A pointer can be re-seated (i.e., pointed at a different object); a
reference cannot.
A reference must be initialized (i.e., its refer-ee specified) when it is
created; a pointer can be uninitialized.




另外一个指针在语法上更方便,你怎么写一个

赋值运算符或复制构造函数而不使用引用?


john



Also a pointer is syntactically more convenient, how would you write an
assignment operator or copy constructor without using references?

john


>
另外一个指针在语法上更方便,怎么会你在不使用引用的情况下编写了一个
赋值运算符或复制构造函数?
Also a pointer is syntactically more convenient, how would you write an
assignment operator or copy constructor without using references?




我的意思是参考在语法上更方便,当然。


john



I mean a REFERENCE is syntactically more convenient, of course.

john


这篇关于C ++:指针Vs引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆