/* */ Click to Join Live Class with Shankar sir Call 9798158723

What is private Members ?

By default all the members of a class would be private,The private data members cannot be accessed from outside the class. They can only be accessed by class or friend functions. All the class members are private by default.When preceding a list of class members, the private keyword specifies that those members are accessible only from member functions and friends of the class. This applies to all members declared up to the next access specifier or the end of the class.A function declared inside the private access specifier of the class, is known as a private member function.

Q.) Example of Private Members Function in C++ .
    #include < iostream>
using namespace std;

class Student
		int rNo;
		float perc;
		//private member functions
		void inputOn(void)
			cout<<"Input start..."<< endl;
		void inputOff(void)
			cout<<"Input end..."<< endl;
		//public member functions
		void read(void)
			//calling first member function
			//read rNo and perc
			cout<<"Enter roll number: ";
			cout<<"Enter percentage: ";
			//calling second member function
		void print(void)
			cout<< endl;
			cout<<"Roll Number: "<< rNo<< endl;
			cout<<"Percentage: "<< perc<<"%"<< endl;

//Main code
int main()
	//declaring object of class student
	Student std;
	//reading and printing details of a student
	return 0;
Input start...
Enter roll number: 101
Enter percentage: 84.02
Input end...
Roll Number: 101
Percentage: 84.02%