Which lines of the code contain errors?

struct A {
  int a;
  public: int b;
  protected: int c;
  private: int d;
};
struct B: public A {
  int fa() {return a;}  //1
  int fb() {return b;}  //2
  int fc() {return c;}  //3
  int fd() {return d;}  //4
};
Explanation
Structs came to C++ from C with default visibility of members public. Structs in C++ can be inherited but private fields are not visible to sub-structs.
C++
C++ Quiz
Start Quiz

or Read more about C++ Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback