473,671 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What does line 162 do ?

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

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
Jun 27 '08 #1
13 1456
Rafael Anschau wrote:
159: static PartsList GlobalPartsList ;
160: };
161:
162: PartsList PartsList::Glob alPartsList;

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
Jun 27 '08 #2
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...@com Acast.netwrote:
Rafael Anschau wrote:
159: static PartsList GlobalPartsList ;
160: };
161:
162: PartsList PartsList::Glob alPartsList;
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
Jun 27 '08 #3
On May 9, 12:26 pm, "Victor Bazarov" <v.Abaza...@com Acast.netwrote:
>Rafael Anschau wrote:
>>159: static PartsList GlobalPartsList ;
160: };
161:
162: PartsList PartsList::Glob alPartsList;
>>I would understand if it initialized the object
GlobalPartsLi st 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::Glob alPartsList; is doing the same thing, it is
just default constructed.
--
Jim Langston
ta*******@rocke tmail.com
Jun 27 '08 #4
Thanks, but same question.

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

[]´s

Rafael
Jun 27 '08 #5
Thanks but same question:

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

[]´s

Rafael
Jun 27 '08 #6
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
Jun 27 '08 #7
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::Glob alPartsList.doS omthing()

Jun 27 '08 #8
Thank you now I get it. The purpose is to make members avalible
and run the constructor. Great.

[]´s

Rafael
Jun 27 '08 #9
>Sorry, I for one don't understand. "Brackets's "?

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

[]´s

Rafael
Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
14712
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 software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
121
10042
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 support IDEs are DreamWeaver 8 and Zend PHP Studio. DreamWeaver provides full support for Unicode. However, DreamWeaver is a web editor rather than a PHP IDE. It only supports basic IntelliSense (or code completion) and doesn't have anything...
1
2179
by: vishal | last post by:
What does #line 182 parser.y mean in a C program?
5
18473
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 pattern as below: %%
2
10473
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 about it then please help me out. Thanks, Dilip
0
8483
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8673
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6236
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5703
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2818
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2060
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.