The correct answer is: A. a colon.
A derived class name is separated from its access specifier with a colon. For example, the following code defines a derived class named Derived from the base class Base:
“`class Base {
public:
void foo() {
std::cout << “Base::foo()\n”;
}
};
class Derived : public Base {
public:
void foo() {
std::cout << “Derived::foo()\n”;
}
};
“`
When a derived class is defined, the name of the base class is followed by a colon and the name of the derived class.
The access specifier for the derived class is then specified, followed by the body of the derived class.In the above example, the derived class Derived is defined to have public access. This means that the members of the derived class can be accessed from any other class in the program.
The access specifier for a derived class can be any of the following:
- public: The members of the derived class can be accessed from any other class in the program.
- protected: The members of the derived class can be accessed from any class in the same derived class hierarchy.
- private: The members of the derived class can only be accessed from the derived class itself.