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 13 1435
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
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
On May 9, 12:26 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
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
On May 9, 12:26 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>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.
Rafael Anschau 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 ?
[]´s
Please do not top post. Message rearranged.
Since GlobalPartsList is static, there can be only one in the program.
There can be only one definition.
Line 162 is simply *the* definition. Line 159 is the declaration. You can
not define a static variable inside a class declaration, you can only
declare it. So outside the class declaration you need the definition, which
you have.
It may make more sense if it was an int.
class foo
{
static int bar;
};
int foo::bar = 42;
Your PartsList PartsList::GlobalPartsList; is doing the same thing, it is
just default constructed.
--
Jim Langston ta*******@rocketmail.com
Thanks, but same question.
int foo::bar = 42;//OK, =42
int foo::bar; //??
[]´s
Rafael
Thanks but same question:
int foo::bar = 42; //Ok, =42
int foo::bar;// ?? =??
[]´s
Rafael
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.
[]´s
Sorry, I for one don't understand. "Brackets's"?
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On May 9, 8:43 am, Rafael Anschau <rafael.ansc...@gmail.comwrote:
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()
Thank you now I get it. The purpose is to make members avalible
and run the constructor. Great.
[]´s
Rafael
>Sorry, I for one don't understand. "Brackets's"?
That´s an old 80´s 90´s (70´s ?) electronic compliment.
[]´s
Rafael
On 9 mai, 20:09, Rafael Anschau <rafael.ansc...@gmail.comwrote:
Thank you now I get it. The purpose is to make members
avalible and run the constructor.
Or not. Even if the object doesn't have a constructor, you need
a definition. Very basically, it's the definition which
allocates the memory for the object (or causes the
compiler/linker to allocate it).
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Rafael Anschau wrote:
>>Sorry, I for one don't understand. "Brackets's"?
That´s an old 80´s 90´s (70´s ?) electronic compliment.
[]´s
But it's probably supposed to use the apostrohpe (') and not the
french "accent aigu" over an empty space (´).
Rafael Anschau wrote:
Thank you now I get it. The purpose is to make members avalible
and run the constructor. Great.
No, it isn't. Think of the declaration as an entry in the table of contents
in a book. It tells you which chapters exist and how to find them, but it
doesn't contain the actual chapter text. So you need to add the chapter
content somwehere to your book, just like you need to define the static
member variable somewhere, since otherwise, the TOC entry leads to nowhere.
Rafael Anschau wrote:
>>Sorry, I for one don't understand. "Brackets's"?
That´s an old 80´s 90´s (70´s ?) electronic compliment.
[]´s
But it's probably supposed to be using an apostrophe and not an acute accent
over an empty space. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sarah Tanembaum |
last post by:
Beside its an opensource and supported by community, what's the fundamental
differences between PostgreSQL and those high-price commercial database (and
some are bloated such as Oracle) from...
|
by: typingcat |
last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so
on. I've tried many PHP IDEs today, but almost non of them supported
Unicode (UTF-8) file.
I've found that the only Unicode...
|
by: vishal |
last post by:
What does
#line 182 parser.y
mean in a C program?
|
by: Matthew Zhou |
last post by:
I check the ISO 9899 standard,
\r (carriage return) Movesthe active position to the initial position
of the current line.
What does it do? How to input?
I tried to use Flex to check this...
|
by: Dilip7597 |
last post by:
Hello Guys,
while checking one of the program, I found one difficulty with my program. there was a condition like (!!a), and I don't know what does it means. So if anybody knows...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |