1User
1User

Reputation: 612

can any one explain the difference

n3035 says: (2010-02-16)

A variable is introduced by the declaration of an object. The variable's name denotes the object.

n3090 says: (2010-03-29)

A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable's name denotes the reference or object.

n3242 says: (2011-02-28)

A variable is introduced by the declaration of a reference other than a non-static data member or of an object. The variable's name denotes the reference or object.

CAN any one explain the difference interms (or) with the help of an program(exactly what it say's)

this is the statement from ISO standard C++

I seen this link :

Why was the definition of a variable changed during the development of C++11?

but this is not(full meaning) my question ...

Upvotes: 11

Views: 318

Answers (2)

Tony Delroy
Tony Delroy

Reputation: 106244

Consider:

int x = 42;
int& rx = x;

x is a variable; should rx also be considered a variable? Many of the Standard's requirements about non-reference variables also apply to references. It's obviously a pain to have to stipulate "variables or references to variables" constantly throughout the Standard, so if the definition of a variable can include references - perhaps with the occasional "except for references", then the Standard may be - on balance - simplified. It looks to me like the revisions were exploring this balance.

Upvotes: 7

Prasoon Saurav
Prasoon Saurav

Reputation: 92942

This was a CWG defect #633 in ISO C++03

Also check out n2993 that deals with core issue# 633 i.e "Specifications for variables that should also apply to references"

The goal of these changes is to expand the meaning of "variable" to encompass both named objects and references, and to apply the term consistently wherever feasible.

Upvotes: 6

Related Questions