This repository contains solutions to OOPS-based coding questions.
Topics covered: 1.Classes & Objects 2.Constructor and destructor. 3. Inheritance 4.Abstraction 5.Polymorphism 6.Operator overloading. 7. Virtual functions.
A constructor is a special member function of a class that is automatically invoked when an object is created. It is mainly used to initialize object members. A destructor is a special member function that is automatically invoked when an object goes out of scope or is destroyed. It is used to free allocated memory and perform cleanup operations.
Types of Constructors
- Default Constructor
- Does not accept parameters.
- Used to set default values for object members.
- Parameterized Constructor
- Accepts parameters.
- Used to initialize member variables with given values.
- Copy Constructor
- Used to create a new object from an existing object of the same class.
- Copy Assignment Operator
- Used to copy data from one already-existing object to another existing object.
- Move Constructor
- Transfers ownership of resources from one object to another.
- Move Assignment Operator
- Transfers ownership from one existing object to another existing object.