A C++ PROGRAM WITH CLASS
MAKING AN OUTSIDE FUNCTION INLINE
NESTING OF MEMBER FUNCTION
When a member function can be called by using its name inside another member function of the same class, it is known as nesting of member function.
Ex -
}
void set :: display(void)
{
cout << ìlargest value = ì <<largest();
}
main()
{
set a
a.input();
a.display();
}
PRIVATE MEMBER FUNCTION
i) Although we place all data items in a private section and all the functions in public, some situation may require certain function to be hidden from the outside calls.
ii) We can place these functions in the private section. 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.
iii) Consider following class:
{
int m;
void read(void);
public:
void update(void);
void write(void);
};
If s1 is an object of sample then
s1.read(); // will not work , object cannot access private data.
read() can be called by the function update() to update the value of m.
read(); // a simple call
}
ALSO SEARCH:
"example of member function in C++"
"types of member function in C++"
"data members in C++"
"private member function in C++"
"classes in C++ example program"
"how to define member function outside the class in C++"
"example of member function in c"
"types of member function in c"
"data members in c"
"how to define member function outside the class in c"
"private member function in c"