Up |
|
|
  |
Author: Rafael AnschauRafael 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 |
|
  |
Author: Victor BazarovVictor 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 |
|
  |
Author: Rafael AnschauRafael 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 |
|
  |
Author: Jim LangstonJim 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 |
|
  |
Author: Rafael AnschauRafael Anschau Date: May 9, 2008 09:29
Thanks, but same question.
int foo::bar = 42;//OK, =42
int foo::bar; //??
[]´s
Rafael
|
| |
| no comments |
|
  |
Author: Rafael AnschauRafael Anschau Date: May 9, 2008 09:36
Thanks but same question:
int foo::bar = 42; //Ok, =42
int foo::bar;// ?? =??
[]´s
Rafael
|
| |
| no comments |
|
  |
Author: Victor BazarovVictor 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 |
|
  |
Author: Martin YorkMartin 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 |
|
  |
Author: Rafael AnschauRafael 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 |
|
  |
|
|
  |
Author: Rafael AnschauRafael 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 |
  |
|
|
|
|
|
|