Networking, Programming and Graphics Tutorials

Private member functions - C++ [1/1]

Type:
Private member functions - C++
Level: Intermediate Networking, Programming and Graphics Tutorials Networking, Programming and Graphics Tutorials 
Private member functions - C++
Date: 2006-Dec-05
Private member functions - C++
Visited: 1275 times
Private member functions - C++
Rating: Private member functions - C++
Private member functions - C++
Author: Alex Plumpton

A private member function can only be called by another function that is a member of its class. Even an object cannot invoke a private function using the dot operator. The example shown in the figure, illustrates the usage of private member functions. If n1 is an object of member, then the statement n1.input(); will not work because objects cannot access private members. However, the function input() can be called by the function updated to update the value of n.

Example:

Class member
{
int n;
void input(void); // private member function
public:
void update(void);
void output(void);
};
void member:: update(void)
{
input(); //simple call,no object used.
}

Rate this tutorial:                    
Networking, Programming and Graphics Tutorials - Private member functions - C++ [1/1] - Networking, Programming and Graphics Tutorials

Need a specific tutorial? Do not hesitate and submit a request!
Related Tags: private member functions  c++ private member functions example  private member functions in c++  C++ + member functions as private  private member functions in c++  c++ private member functions  implementation of private member functions C++  access private member functions  accessing private member functions  How to write C++ code for member elements and member functions