[Nit] Re: Private constructor
From: Jeff Schwab (jeffplus_at_comcast.net)
Date: 12/20/03
- Next message: Ron Natalie: "Re: Ptrs to member funcs & inheritance"
- Previous message: Ron Natalie: "Re: Private constructor"
- In reply to: Ron Natalie: "Re: Private constructor"
- Next in thread: Ron Natalie: "Re: [Nit] Re: Private constructor"
- Reply: Ron Natalie: "Re: [Nit] Re: Private constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 20 Dec 2003 10:39:02 -0500
Ron Natalie wrote:
> "Andy" <garth_rockett@yahoo.com> wrote in message
> news:96dbbc80.0312200331.5098622c@posting.google.com...
>
>><
>>I am sorry I made a stupid mistake. I was under the impression that
>>just as static functions cannot access instance data members of a
>>class, they also cannot call non-static member functions. Of course
>>member functions are not per instance even if they are made to look
>>that way. Constructor being a special kind of such a function should
>>be accessible from static member functions.
>>
>>That was stupider on second thoughts. A constructor does not get a
>>this pointer secretly. So it's not a special kind of the others ... it
>>is special and different from the rest. Nevertheless, I think I am
>>right in assuming that neither the member functions nor the
>>constructor or destructor constitute the state of an instantiated
>>object - therefore static member functions should be able to access
>>them
>
>
> I have no clue what you are talking about. Constructors are non-static
> member functions. You can't call them.
<nit> Yes, you can. Allocators do it all the time. </nit>
> They do have this pointers.
> You're confusing access with instantiation. A static member function
> has access to the private members of other objects of the same class
> just like non-static members of one object can access private
> members of other instances of the class.
Right on.
- Next message: Ron Natalie: "Re: Ptrs to member funcs & inheritance"
- Previous message: Ron Natalie: "Re: Private constructor"
- In reply to: Ron Natalie: "Re: Private constructor"
- Next in thread: Ron Natalie: "Re: [Nit] Re: Private constructor"
- Reply: Ron Natalie: "Re: [Nit] Re: Private constructor"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|