Answers for "which of the following calls to ohai() are valid"

0

which of the following calls to ohai() are valid

error: ‘void A::ohai()’ is inaccessible
 struct A { void ohai() {} };
             ^
main.cpp:20:11: error: within this context
  B().ohai();
       ^
main.cpp:8:17: error: ‘void A::ohai()’ is inaccessible
 struct A { void ohai() {} };
             ^
main.cpp:22:11: error: within this context
  D().ohai();
Posted by: Guest on February-05-2021
0

which of the following calls to ohai() are valid

struct A { void ohai() {} };

struct B: protected A {};

struct C: private A { friend int main();};

struct D: B { void test() { ohai();} };

struct E: C { void test() { ohai();} };

int main() {
    A().ohai();
    B().ohai();
    C().ohai();
    D().ohai();    
    return 0;
}
Posted by: Guest on February-05-2021

Code answers related to "which of the following calls to ohai() are valid"

Browse Popular Code Answers by Language