Solved

pointer to class confusion?

Posted on 2013-06-07
2
442 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
Comment Utility
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
Comment Utility
Very fast and accurate response.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

743 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

18 Experts available now in Live!

Get 1:1 Help Now