Solved

pointer to class confusion?

Posted on 2013-06-07
2
444 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
 

Author Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now