What does line 162 do ?
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.c++ Profile…
 Up
What does line 162 do ?         


Author: Rafael Anschau
Date: May 9, 2008 08:18

159: static PartsList GlobalPartsList;
160: };
161:
162: PartsList PartsList::GlobalPartsList;

I would understand if it initialized the object
GlobalPartsList with some value, but as it is now, it seems to me
without purpose.

Thanks,

Rafael
12 Comments
Re: What does line 162 do ?         


Author: Victor Bazarov
Date: May 9, 2008 08:26

Rafael Anschau wrote:
> 159: static PartsList GlobalPartsList;
> 160: };
> 161:
> 162: PartsList PartsList::GlobalPartsList;
>
> I would understand if it initialized the object
> GlobalPartsList with some value, but as it is now, it seems to me
> without purpose.

It _defines_ the static data member. Read up on static data members.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
no comments
Re: What does line 162 do ?         


Author: Rafael Anschau
Date: May 9, 2008 08:43

Yes, my text says it initializes or defines it there. That line 159
only declares it.
But initializes it, defines it with what ? What it does is to make it
possible to later assign
a value ?

[]´s

Rafael
Show full article (0.76Kb)
no comments
Re: What does line 162 do ?         


Author: Jim Langston
Date: May 9, 2008 08:57

> On May 9, 12:26 pm, "Victor Bazarov" comAcast.net> wrote:
>> Rafael Anschau wrote:
>>> 159: static PartsList GlobalPartsList;
>>> 160: };
>>> 161:
>>> 162: PartsList PartsList::GlobalPartsList;
>>
>>> I would understand if it initialized the object
>>> GlobalPartsList with some value, but as it is now, it seems to me
>>> without purpose.
>>
>> It _defines_ the static data member. Read up on static data members.
Show full article (0.67Kb)
no comments
Re: What does line 162 do ?         


Author: Rafael Anschau
Date: May 9, 2008 09:29

Thanks, but same question.

int foo::bar = 42;//OK, =42
int foo::bar; //??

[]´s

Rafael
no comments
Re: What does line 162 do ?         


Author: Rafael Anschau
Date: May 9, 2008 09:36

Thanks but same question:

int foo::bar = 42; //Ok, =42
int foo::bar;// ?? =??

[]´s

Rafael
no comments
Re: What does line 162 do ?         


Author: Victor Bazarov
Date: May 9, 2008 09:56

Rafael Anschau wrote:
> Thanks, but same question.
>
> int foo::bar = 42;//OK, =42
> int foo::bar; //??

If your question is what value 'foo::bar' gets, the answer is 0.
> []
no comments
Re: What does line 162 do ?         


Author: Martin York
Date: May 9, 2008 10:02

On May 9, 8:43 am, Rafael Anschau gmail.com> wrote:
> Yes, my text says it initializes or defines it there. That line 159
> only declares it.
> But initializes it, defines it with what ? What it does is to make it
> possible to later assign
> a value ?

When an object is initialised it calls the objects constructor.
So line 162 creates the object and calls the objects constructor (see
constructor for PartsList). Once it has been constructed you can now
call all the public methods available in PartsList.

PartsList::GlobalPartsList.doSomthing()
no comments
Re: What does line 162 do ?         


Author: Rafael Anschau
Date: May 9, 2008 11:09

Thank you now I get it. The purpose is to make members avalible
and run the constructor. Great.

[]´s

Rafael
no comments
Re: What does line 162 do ?         


Author: Rafael Anschau
Date: May 9, 2008 11:09

>Sorry, I for one don't understand. "Brackets's"?

That´s an old 80´s 90´s (70´s ?) electronic compliment.

[]´s

Rafael
no comments

RELATED THREADS
SubjectArticles qty Group
[email][67.162.172.69 US AS22909 67.162.160.0/20]news.admin.netabuse.sightings ·
[email][78.162.31.50 TR AS9121 78.162.0.0/17] Augustnews.admin.netabuse.sightings ·
[email][68.162.67.226 US AS19262 68.162.64.0/19] Best replica watchesnews.admin.netabuse.sightings ·
 
1 2