Networking, Programming and Graphics Tutorials

Pointers to members - C++ [1/1]

Type:
Pointers to members - C++
Level: Expert Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials 
Pointers to members - C++
Date: 2006-Dec-08
Pointers to members - C++
Visited: 1054 times
Pointers to members - C++
Rating: Pointers to members - C++
Pointers to members - C++
Author: Alex Plumpton

C ++ allows you to generate a special type of pointer that points to a member of a class, not to a specific instance of that member in an object. This sort of pointer is called a pointer to a class member or pointer-to-member. The figure shown, illustrates the usage of pointer to members.

Pointers to members - C++
Pointers To Members
int stud :: *info =&stud::id;

The info pointer, thus created, acts like a class member in that it must be invoked with a class object. In the statement, the phrase stud::' means "pointer- to —member ofstutl class". The phrase &stud:: id means the "address ofthe id member of stud class". The pointer info can now be used to access the memberid inside member functions.

Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Pointers to members - C++ [1/1] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: pointers-to-members c++  access class members in c++ + pointers  c static data members  c++ access to members classes  +c++ +"static data members"  Objects as members of classes in C++  private members that are arrays c++  private members that are arrays c++  description of "static data members" C++  virtual private members C++ tutorial