CS Electrical And Electronics
@cselectricalandelectronics

From the following code, protected member is f1 is accessible in

All QuestionsCategory: Cpp LanguageFrom the following code, protected member is f1 is accessible in
Anonymous asked 3 years ago

class X {
protected:
void f1() {
};
class Y: public X {};
class Z: public Y{};
class P{};
void test() {  }
 
Options:
 

  1. X, Y, Z, & P
  2. X, Y, Z, P, & test
  3. X, Y, Z only
  4. X only