CS Electrical And Electronics
@cselectricalandelectronics

What is private, protected and public access specifier in cpp, explain with example?

All QuestionsCategory: Cpp LanguageWhat is private, protected and public access specifier in cpp, explain with example?
CS Electrical And Electronics Staff asked 4 years ago

I need short information.

1 Answers
CS Electrical And Electronics Staff answered 4 years ago

class chetan
{
     private:
      ……
     protected:
      ……
      public:
      ……
};
 

  1. The private access specifier is only visible to member functions within its class.
  2. The protected access specifier is only visible to member functions of its own and derived class.
  3. The public access specifier is only visible to all functions in the program.