Which is correct syntax of inheritance?

2023

Which is correct syntax of inheritance?

  1. A.

    class base_classname : access derived_classname

    {

    /* define class body */

    };

  2. B.

    class derived_classname : access base_classname

    {

    /* define class body */

    };

  3. C.

    class derived_classname : base_classname

    {

    /* define class body */

    };

  4. D.

    More than one of the above

  5. E.

    None of the above

Attempted by 317 students.

Show answer & explanation

Correct answer: B

The correct syntax for C++ inheritance is: class derived_classname : access_specifier base_classname { ... };. Option B matches this. Option A reverses the order. Option C is missing the access specifier. Option D and E are incorrect as only B is valid.

Explore the full course: Up Lt Grade Assistant Teacher 2025