If the people ask what is the different between pointer and reference,
what is the brief and good answer?
I say " pointer could point to NULL, but there is no null reference",
What is your opinion?
Vol
Aug 1 '06
14 7189
"Victor Bazarov" <v.********@com Acast.netwrote in message
news:ea******** **@news.datemas .de...
Howard wrote:
>"Kaz Kylheku" <kk******@gmail .comwrote in message news:11******* *************** @m73g2000cwd.go oglegroups.com. ..
>>Vols wrote: If the people ask what is the different between pointer and reference, what is the brief and good answer?
Brief and good answer:
In the context of C++, a reference is a declarative and type casting gadget which causes an object itself to be propagated rather than a copy of its value.
What??? What's a "declarativ e and type casting gadget", and what does a reference have to do with type casting?
A reference is simply an "alias" for an existing object.
I think you need to remember that references help using objects
polymorphically .
True. I probably should have left out "simply" in my answer. A good C++
book is undoubtedly the best place for a complete description of references,
(not someone's "brief and good answer").
-Howard
Howard wrote:
True. I probably should have left out "simply" in my answer.
Or you should have simply left out your clueless answer.
"Kaz Kylheku" <kk******@gmail .comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Howard wrote:
>True. I probably should have left out "simply" in my answer.
Or you should have simply left out your clueless answer.
Instead of a personal attack, you could let us know what you meant by your
own answer. Specifically, what do you mean by: "a declarative and type
casting gadget".
Also, it's not that clear what you meant when you said it "causes an object
itself to be propogated". A reference "refers" to another object. It's an
alias for that object. Propogation implies some sort of movement or
copying.
-Howard
Howard wrote:
"Kaz Kylheku" <kk******@gmail .comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
Vols wrote:
If the people ask what is the different between pointer and reference,
what is the brief and good answer?
Brief and good answer:
In the context of C++, a reference is a declarative and type casting
gadget which causes an object itself to be propagated rather than a
copy of its value.
What??? What's a "declarativ e and type casting gadget", and what does a
English lesson:
A gadget is a mechanism; a device. In a programming language, that is
syntax plus semantics. Declarative means having to do with
declarations, and type casting means having to do with type casts.
reference have to do with type casting?
Gee, I don't know! How about :
void func(Base &b)
{
Derived d = dynamic_cast<De rived &>(b);
}
That is a reference cast. Here, the reference isn't used to declare
anything. So if I had said that references were declarative gadget, I
would have missed the type casting use.
A reference is simply an "alias" for an existing object.
You're just parroting an oft repeated statement that only applies to
block scope reference variables. It is misleading to varying degrees if
applied to other situations. Entities which are not object-like can be
attributed as entities, such as function return values.
Also, when would an alias ever be constructed for a NON-existing
object?
"Kaz Kylheku" <kk******@gmail .comwrote in message
news:11******** **************@ m79g2000cwm.goo glegroups.com.. .
>
Howard wrote:
>"Kaz Kylheku" <kk******@gmail .comwrote in message news:11******* *************** @m73g2000cwd.go oglegroups.com. ..
Vols wrote: If the people ask what is the different between pointer and reference, what is the brief and good answer?
Brief and good answer:
In the context of C++, a reference is a declarative and type casting
gadget which causes an object itself to be propagated rather than a
copy of its value.
What??? What's a "declarativ e and type casting gadget", and what does a
English lesson:
A gadget is a mechanism; a device. In a programming language, that is
syntax plus semantics. Declarative means having to do with
declarations, and type casting means having to do with type casts.
>reference have to do with type casting?
Gee, I don't know! How about:
void func(Base &b)
{
Derived d = dynamic_cast<De rived &>(b);
}
That is a reference cast. Here, the reference isn't used to declare
anything. So if I had said that references were declarative gadget, I
would have missed the type casting use.
The fact that you can cast something to a reference doesn't make the
reference a "type casting gadget". Your original statement was made to
someone who is a newbie, who didn't understand what a reference was. I
think your explanation was not very helpful in that context. That's why I
asked you to clarify it. I apologize if my reply sounded arrogant (esp. by
using the ???).
>A reference is simply an "alias" for an existing object.
You're just parroting an oft repeated statement that only applies to
block scope reference variables. It is misleading to varying degrees if
applied to other situations. Entities which are not object-like can be
attributed as entities, such as function return values.
Also, when would an alias ever be constructed for a NON-existing
object?
Oh, come on!
I don't mind discussing issues here, even if I'm shown to be wrong. But can
we keep this on a professional level?
-Howard This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: CoolPint |
last post by:
Can anyone clearly explain the difference between constant reference to
pointers and reference to constant pointers?
What is const int * & ?
Is it a constant reference to a pointer to an integer? Or
Is it a reference to a pointer to a constant integer?
What is being constant in this case? The pointer or the integer being pointed?
How about int * const & ?
Is this a reference to a constant pointer to an integer? Or
|
by: TonyJeffs |
last post by:
Great book - I like the way that unlike other books, AC++ explains as
much as possible about every piece of code discussed, so I'm not left
thinking, "well...OK... I get line 12, but I wonder what the rest of
it means...".
Still, I have some questions, that are frustrating me:-
Grateful for any comments.
1. What is the difference between
#include <iostream> // (or any include file) which is used in this
|
by: Tony Johansson |
last post by:
Hello!
I'm reading a book about C++ and there is something that I don't understand
so I ask you.
I have marked the section from the book that is of intertest by tagging it
with BOOK START HERE and ending with BOOK ENDING HERE. All that text between
is just a copy from the book.
My question come after the text section.
The book says
|
by: z_learning_tester |
last post by:
I'm reading the MS press C# book and there seems to be a contradiction.
Please tell me which one is correct, 1 or 2.
Thanks!
Jeff
1. First it gives the code below saying that it prints 0 then 42.
They say that 42 is printed the second time since the value was wrapped in a
class and therefore became passed by reference.
(sorry for any typos I am a newbie here ;-)
|
by: Duncan Mole |
last post by:
Hi,
This is probably an easy one but it iy first bit of p/invoke. I am trying to
use the following C struct in a call:
typedef struct
{
BYTE SRB_Cmd;
BYTE SRB_Status,
BYTE SRB_HaId;
| |
by: Diffident |
last post by:
Hello All,
I have a question which is pertinent to Page's lifecycle.
I declared a protected static object (global variable within that class)
whose value is set only once when the page is loaded. Will that object's
value be accessible
during consequent postbacks or is it set to null after HTML is rendered
initially?
|
by: ravi |
last post by:
Hi,
i am a c++ programmer,
now i want to learn programming in c also.
so can anybody explain me the difference b/w call by reference and
call by
pointer (with example if possible).
|
by: tshad |
last post by:
Using VS 2003, I am trying to take a class that I created to create new
variable types to handle nulls and track changes to standard variable types.
This is for use with database variables. This tells me if a variable has
changed, give me the original and current value, and whether the current
value and original value is/was null or not.
This one works fine but is recreating the same methods over and over for
each variable type.
...
|
by: Logos |
last post by:
I have what may be a bug, or may be a misunderstanding on how pass by
reference and class inheritance works in PHP. Since I'm relatively
new to PHP, I'm hoping for a little outside help to shed some light on
this!
(code abbreviated for clarity)
I have a parent class, DetailCollection, with a child class
KeycodeTracker:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |