variable shadow

B

Black Ice

If any compiler will give warning when meed variable show.
Following is the example code:
void foo()
{
int total;
if(...)
{
int total;
...
}
}


--


Regards,
Black Ice

Çë²»Òª»Ø¸´µ½ÎÒµÄÓÊÏä

×ÔÓÉ£¨liberty£©Î޷ǾÍÊÇÕâÑùÒ»ÖÖ³Ðŵ£ºÃ¿¸öÈ˽«»áµÃµ½Ò»ÖÖ±£ÕÏ£¬±£ÕÏÎÒÃÇ¿ÉÒÔÓë
ȨÍþ¡¢¶àÊý¡¢Á÷Ë×¼°ÓßÂÛµÄÓ°ÏìÏ࿹ºâ¡£

http://www.leoliu.net
 
V

Victor Bazarov

Black Ice said:
If any compiler will give warning when meed variable show.

I am not sure I understand that sentence. 'Meed' is a noun. Used
with another noun ('variable') it becomes an attribute. "Meed
variable" is "earned reward variable"?... I don't understand.
Following is the example code:
void foo()
{
int total;
if(...)
{
int total;
...
}
}

No, in most cases no warning will be given. Name hiding (that's
the C++ term) is a legal C++ construct and used often.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top