Solved

pointer to class confusion?

Posted on 2013-06-07
2
447 Views
Last Modified: 2013-06-07
Please consider following class:

class SomeTask
{
 
  public:
     SomeTask();
    ~SomeTask();
    void initialize();
     
  private:  
    InterfaceTask *_serviceInterface;
    Protocol * Protocol;
     
    static SomeTask *_instance;  
 
};

Then consider the following:

SomeTask * SomeTask::_instance = NULL;


Please explain "SomeTask::_instance" pointer.  Is private member _instance getting accessed outside the class?  What is this ::  notation mean?
0
Comment
Question by:naseeam
2 Comments
 
LVL 40

Accepted Solution

by:
evilrix earned 500 total points
ID: 39228964
That's the correct notation to initialise a static data member. There is no other way to do it. The fact is is private makes no difference. Once it's initialised it can only be accessed from class members.
0
 
LVL 1

Author Closing Comment

by:naseeam
ID: 39228984
Very fast and accurate response.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question