accessing class member and doing nothing ?

I have this PartsList class from the book I'm currently learning.
For understanding context: the PartsList consists of PartNodes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class PartsList
{
public:
	PartsList();
	~PartsList();
	(some stuff)
	static PartsList& GetGlobalPartsList() { return GlobalPartsList; }
private: 
	PartNode * pHead;	 
	int itsCount;
        static PartsList GlobalPartsList;
};


PartsList PartsList::GlobalPartsList; // ?

PartsList::PartsList():pHead(0), itsCount(0) {} // default constr. implementation + init 

PartsList::~PartsList() { delete pHead; } // destr. implementation
(...)


What is
 
PartsList PartsList::GlobalPartsList;


It's accessing private GlobalPartsList member and then - doing nothing with it, it seems to me ?


Last edited on
Static data members have to be defined (exactly once):
https://msdn.microsoft.com/en-us/library/b1b5y48f.aspx
It is a definition of static variable declared inside your class. In your case it is created using default constructor.
Thank you both. That link is a spot on example, got it.

(Actually I've learned this about static members already but forgotten again, arrrrg. So much to learn and keep in mind :))
Topic archived. No new replies allowed.