• Advertisement
Sign in to follow this  

Just a quick question about scope in C++.

This topic is 4480 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Guest Anonymous Poster
local

Share this post


Link to post
Share on other sites
Local takes precedence; this is known as identifier shadowing. If your compiler does not complain loudly about you doing this, you need to up your warnings levels [wink]


rip-off is exactly right. If you need similar identifiers, strongly consider using a namespace or some other grouping mechanism to avoid shadowing. The compiler can figure it out just fine, but I guarantee that at some point, it'll confuse you...

Share this post


Link to post
Share on other sites
Thanks for all the feedback, and the warnings! It's not actually for use in a program, I am working my way through every C++ exam/test/quiz/multiple choice I can find in preparation for interviews which I will *hopefully* be having when I get my demos finished.

Mark

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement