Re: Private constructor
From: Ron Natalie (ron_at_sensor.com)
Date: 12/21/03
- Next message: Ron Natalie: "Re: Static Member Functions and inheritence"
- Previous message: Victor Bazarov: "Re: Scripting Language Tutorial"
- In reply to: Andy: "Re: Private constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 21 Dec 2003 13:45:01 -0500
"Andy" <garth_rockett@yahoo.com> wrote in message news:96dbbc80.0312210934.4b902a49@posting.google.com...
> 1) Static member functions cannot access any non-static data members
> of a class.
They can if they access it through a pointer or a reference. You are right, they
can't without as they have no "this" object to get the member from. However, given
an object pointer they can get access to the private non-static members on the object.
>
> With constructors, this is different although they are non-static. The
> static member function can instantiate an object of the class it
> belongs to. This is what I found out.
It's not really that different. The static member can create an object of the
type because the constructor is ACCESSIBLE (i.e., the private/protected/public
rules).
You see there are two different principles here:
static versus non-static (I don't know what to call this distinction in general).
Access control (which is the public/private/static protected rules).
- Next message: Ron Natalie: "Re: Static Member Functions and inheritence"
- Previous message: Victor Bazarov: "Re: Scripting Language Tutorial"
- In reply to: Andy: "Re: Private constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|