Computer Science, asked by shyamkumarb612, 3 months ago

what is the privete and public in the c++​

Answers

Answered by Mayura680
1

Answer:

C++ offers the possibility to control access to class members and functions by using access specifiers. Access specifiers are used to protecting data from misuse.

Public Specifier

Public class members and functions can be used from outside of a class by any function or other classes. You can access public data members or function directly by using dot operator (.) or (arrow operator-> with pointers).

Protected Specifier

Protected class members and functions can be used inside its class. Protected members and functions cannot be accessed from other classes directly. Additionally protected access specifier allows friend functions and classes to access these data members and functions. Protected data members and functions can be used by the class derived from this class. More information about access modifiers and inheritance can be found in C++

Explanation:

Please make as Brainlist answer

Answered by Anonymous
2

\huge\bf\underline{\red{A}\green{N}\orange{S}\pink{W}\purple{E}\blue{R}}.

\huge{\underline{\boxed{\rm{PUBLIC}}}}

All the class members declared under public will be available to everyone. The data members and member functions declared public can be accessed by other classes too. The public members of a class can be accessed from anywhere in the program using the direct member access operator (.) with the object of that class.

\huge{\underline{\boxed{\rm{PRIVATE}}}}

The class members declared as private can be accessed only by the functions inside the class. They are not allowed to be accessed directly by any object or function outside the class. Only the member functions or the friend functions are allowed to access the private data members of a class.

Similar questions