Difference between Base class and Derived class in C++ Last Updated : 22 Mar, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report Base Class: A base class is a class in Object-Oriented Programming language, from which other classes are derived. The class which inherits the base class has all members of a base class as well as can also have some additional properties. The Base class members and member functions are inherited to Object of the derived class. A base class is also called parent class or superclass.Derived Class: A class that is created from an existing class. The derived class inherits all members and member functions of a base class. The derived class can have more functionality with respect to the Base class and can easily access the Base class. A Derived class is also called a child class or subclass.Syntax for creating Derive Class: class BaseClass{ // members.... // member function } class DerivedClass : public BaseClass{ // members.... // member function } Difference between Base Class and Derived Class: S.No.BASE CLASSDERIVED CLASS1. A class from which properties are inherited.A class from which is inherited from the base class.2. It is also known as parent class or superclass.It is also known as child class subclass.3. It cannot inherit properties and methods of Derived Class.It can inherit properties and methods of Base Class.4. Syntax: class BaseClass{ // members.... // member function } Syntax: class DerivedClass : access_specifier BaseClass{ // members.... // member function } Below is the program to illustrate Base Class and Derived Class: CPP // C++ program to illustrate // Base & Derived Class #include <iostream> using namespace std; // Declare Base Class class Base { public: int a; }; // Declare Derived Class class Derived : public Base { public: int b; }; // Driver Code int main() { // Initialise a Derived class geeks Derived geeks; // Assign value to Derived class variable geeks.b = 3; // Assign value to Base class variable // via derived class geeks.a = 4; cout << "Value from derived class: " << geeks.b << endl; cout << "Value from base class: " << geeks.a << endl; return 0; } Output: Value from derived class: 3 Value from base class: 4 Comment More infoAdvertise with us Next Article Difference between Base class and Derived class in C++ V vanshikagoyal43 Follow Improve Article Tags : Difference Between C++ cpp-inheritance C++-Inheritance Inheritance +1 More Practice Tags : CPP Similar Reads Difference Between Structure and Class in C++ In C++, a structure works the same way as a class, except for just two small differences. The most important of them is hiding implementation details. A structure will by default not hide its implementation details from whoever uses it in code, while a class by default hides all its implementation d 3 min read Difference Between Constructor and Destructor in C++ ConstructorA constructor is a member function of a class that has the same name as the class name. It helps to initialize the object of a class. It can either accept the arguments or not. It is used to allocate the memory to an object of the class. It is called whenever an instance of the class is c 3 min read Catching Base and Derived Classes as Exceptions in C++ and Java An Exception is an unwanted error or hurdle that a program throws while compiling. There are various methods to handle an exception which is termed exceptional handling. Let's discuss what is Exception Handling and how we catch base and derived classes as an exception in C++: If both base and derive 4 min read Difference between fundamental data types and derived data types In computer programming, data type is a classification that specifies to compiler or interpreter which type of data user is intending to use. There are two types of data types - Primitive/Fundamental data type: Each variable in C/C++ has an associated data type. Each data type requires different amo 8 min read Difference Between Compile Time And Run Time Polymorphism In C++ In this article, we will discuss the differences between the compile-time and runtime polymorphism in C++. What is Polymorphism? Poly means many and morph means forms or shape. Thus the word Polymorphism comes from Greek and it basically means having many forms. For example, Your DAD is your father. 4 min read Like