Hi,
I have also posted this to the moderated group. I have 2 classes A >and
B,
what does the following mean in header file for class A:
class A
{
class B &b;
...
Does this imply that the copy is being shared across all instances of
class A?
I know we use static, but I have come across this in a code and am >not
sure what this means..
Replying to Amit (the person asking the question).
Your question has been answered quite professionally in accordance to
the standard. My comment is on a different issue.
The notion of reference is not related to type. In simplest terms, it
creates an alias (another name) for an existing OBJECT. For instance,
in pass by reference, or in the following declaration:
int & r = n;
The identifier r is another name for the object named n.
When defining a class, we are introducing a new type using existing
types. The names of members of class are names of objects (of specified
types). It will take me too long to logically explain that a pointer is
a type (not a type modifier). At any rate, pointer types are needed for
recursive structures like linked lists.
Now, what in the world does it mean for the name of a member of a class
to be an alias for another object? We are defining a type, why does it
have to depend on the existence of an OBJECT? The game played by the
compiler, to wait until we create an instance of our class, and then
require the existence of an object, can be done to accommodate for
anything we want. Except, programming is too hard to be confused with a
game.
I really think now that you know how to read other people's code do
not be encouraged to use it.
Regards,
(e-mail address removed)
http://www.zhmicro.com
http://distributed-software.blogspot.com
http://groups-beta.google.com/group/computerlangZ?lnk=la&hl=en