ExamVeda
Login
Home
Object Oriented Programming in C plus plus
?

Which keyword is used to inherit a class in C++?

Answer & Solution
Correct Answer: Option A
In C++, the keyword public is used to specify public inheritance when inheriting a class.

When a class inherits another class publicly, all public members of the base class become public members of the derived class, and protected members of the base class become protected members of the derived class.

The keywords private and protected can also be used for inheritance, but they specify different levels of access control:

private inheritance: All public and protected members of the base class become private members of the derived class.

protected inheritance: All public and protected members of the base class become protected members of the derived class.

The keyword extends is used in languages like Java for inheritance, but not in C++.

Therefore, the correct answer is public.
Examveda
Question posted by Examveda
Community

Join the Discussion

1 Comment
SUSANTA SWAIN
SUSANTA SWAIN 2 years ago
check the question