Computer Science, asked by rradhikalodha12, 4 months ago

what is Access specifier ?​

Answers

Answered by Thûgłife
2

\bf \large\underline{Access\:specifier }

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 :-

\bf \large\underline{Public:- }

  • 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.

\bf \large\underline{Private:- }

  • 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.

\bf \large\underline{Protected:- }

  • Functions or variables declared using the protected keyword can be accessed by the subclasses only.
Similar questions