Ask Question

A class design requires that a particular member variable must be accessible by any subclasses of this class, but otherwise not by classes which are not members of the same package. What should be done to achieve this?

+2
Answers (1)
  1. 29 July, 03:36
    0
    The variable should be marked protected.

    Explanation:

    When class structure implies that some derived classes of such a class have to control a specific member attribute, but still not that classes which aren't members with a similar package instead. To accomplish this, the variable should be marked with protected because the protected data members are not accessed outside that class in which they are declared.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “A class design requires that a particular member variable must be accessible by any subclasses of this class, but otherwise not by classes ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers