473,418 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Scope rules


Although I rarely if ever have a problem with scope, I was wondering
whether anybody knows of good reference, (book, web page, etc), that
covers scope rules. Hopefully this will be helpful to others.

JB
Jul 20 '06 #1
3 2111
n2xssvv g02gfr12930 wrote:
Although I rarely if ever have a problem with scope, I was wondering
whether anybody knows of good reference, (book, web page, etc), that
covers scope rules. Hopefully this will be helpful to others.
You mean like "Always keep the scope of the name as tight as possible"?
Or do you mean like "overloading only relates to functions in the same
scope" and the related "derived class scope is tighter than the base
class scope (and included in it)"?

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 20 '06 #2
n2xssvv g02gfr12930 posted:

Although I rarely if ever have a problem with scope, I was wondering
whether anybody knows of good reference, (book, web page, etc), that
covers scope rules. Hopefully this will be helpful to others.

A rule of thumb would be:

An object exists from the point of its definition, until the next
closing brace. (Unless it's static of course).
If you define an object within a "for" loop as follows:

for(int i;;) {}
Then its scope is as if you wrote:

{
int i;

for(;;) {}

}
--

Frederick Gotham
Jul 20 '06 #3
Victor Bazarov wrote:
>
You mean like "Always keep the scope of the name as tight as possible"?
Or do you mean like "overloading only relates to functions in the same
scope" and the related "derived class scope is tighter than the base
class scope (and included in it)"?

V
All of those points would be nice, with examples demonstrating the how
and the why. Perhaps I should create some web pages on scope covering
class, namespace, code scope, and any others you'd like to suggest.
Thanks for your response, and no doubt you could think of countless
examples.

JB
Jul 20 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

33
by: Arthur | last post by:
>>>a= >>> for p in a: print p 1 2 3 >>> p 3 My naive expectation was that p would be 'not defined' from outside
7
by: Michael G | last post by:
I am a little surprised that the following that $x is visible outside of the scope in which it is (?)defined(?) (not sure if that is the correct term here). I am trying to find where in the php...
8
by: TTroy | last post by:
I have a few questions about "scope" and "visibility," which seem like two different things. To me "visibility" of the name of a function or object is the actual code that can use it in an...
3
by: fctk | last post by:
are the following rules correct in C89/C90? ---- SCOPE RULES 1) the scope of an identifier declared inside a block is the block in which it is declared; 2) when you have nested blocks...
39
by: utab | last post by:
Dear all, Is there a clear distinction how to decide which functions to be members of a class and which not How is your attitude (Your general way from your experiences ...) "If the...
2
by: James Brown | last post by:
All, Could anyone explain why the following is an error: void foo( struct FOO { int x; } f1 ) { } int main()
5
by: Steven T. Hatton | last post by:
If find the following excerpt from the Standard a bit confusing: <quote> 3.3.6 - Class scope -1- The following rules describe the scope of names declared in classes. 1) The potential scope...
7
by: Johannes Bauer | last post by:
Hello Group, please consider the following code #include <vector> #include <iostream> #define USE_CONST #define USE_STRING
1
by: Tim Haughton | last post by:
Firstly, if there's a better newsgroup to ask this on, feel free to redirect me. I have these requirements of WDS for a project: 1) I need to be able to add a new location to the user scope...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
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,...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.