what is Access specifier ?
Answers
Answered by
2
It is a keyword used for defining how a function or variable can be accessed in the cõde or program from a class.
There are mainly three access specifiers :-
- Functions or varibles declared by public can be access from anywhere. This is usually used when we want the variable or function to be used in various function.
- Functions or variables defined by the private access-specifier can only be accessed in a class and also any function that can access these variables or functions should be a member function of that class. friend functions can also access these variables or functions.
- Functions or variables declared using the protected keyword can be accessed by the subclasses only.
Similar questions