In a class specifier, data or functions designated private are accessible A. to any function in the program B. only if you know the password C. to member functions of that class D. only to public members of the class

[amp_mcq option1=”to any function in the program” option2=”only if you know the password” option3=”to member functions of that class” option4=”only to public members of the class” correct=”option3″]

The correct answer is C. to member functions of that class.

A class is a blueprint for creating objects. It defines the data and functions that an object has. The data and functions of a class are called members. Members can be public, private, or protected.

Public members are accessible to any function in the program. Private members are only accessible to member functions of the class. Protected members are accessible to member functions of the class and to member functions of derived classes.

In a class specifier, data or functions designated private are accessible to member functions of that class only. This means that other functions in the program cannot access private members of a class. This is useful for protecting data and ensuring that it is only accessed by the functions that need it.

Option A is incorrect because private members are not accessible to any function in the program. Option B is incorrect because private members are not accessible by knowing the password. Option D is incorrect because private members are accessible to member functions of the class.

Exit mobile version