Create an abstract class `Employee` with a pure virtual function `calculateSalary()`. Derive classes `FullTime` and `PartTime` and implement salary calculations.

Create an abstract class `Employee` with a pure virtual function `calculateSalary()`. Derive classes `FullTime` and `PartTime` and implement salary calculations. SOLUTION…. C++ Abstract Class Example #include <iostream> using namespace std; // Abstract class class Employee { protected: string name; int empID; public: Employee(string n, int id) : name(n), empID(id) {} virtual void calculateSalary() = 0; […]

Create a base class `Shape` with virtual function `area()`. Derive `Rectangle` and `Triangle` to override `area()` and use a base class pointer to call functions.

Create a base class `Shape` with virtual function `area()`. Derive `Rectangle` and `Triangle` to override `area()` and use a base class pointer to call functions. SOLUTION…. C++ Virtual Function Example #include <iostream> using namespace std; // Base class class Shape { public: virtual void area() { // Virtual function cout << “Base Shape area (not […]

Create classes `Student`, `Test`, `Sports`, and `Result` to demonstrate hybrid inheritance. Accept data and display total marks.

Create classes `Student`, `Test`, `Sports`, and `Result` to demonstrate hybrid inheritance. Accept data and display total marks. SOLUTION…. C++ Hybrid Inheritance Example #include <iostream> using namespace std; // Base Class: Student class Student { protected: int roll; string name; public: void inputStudent() { cout << “Enter Roll No: “; cin >> roll; cout << “Enter […]

Create class `Student` and `Sports` to accept marks and sports score respectively. Derive a class `Result` from both and display total score.Demonstrate multiple Inheritance.

Create class `Student` and `Sports` to accept marks and sports score respectively. Derive a class `Result` from both and display total score.Demonstrate multiple Inheritance. SOLUTION…. Multiple Inheritance in C++ C++ Program: Multiple Inheritance Example #include <iostream> using namespace std; // Base class 1 class Student { protected: int marks; public: void getMarks(int m) { marks […]

Explain Virtual and Pure Virtual function with example.

Q.2 Solution…… Q.2 Explain Virtual and Pure Virtual function with example. Solution :-  Virtual and Pure Virtual Functions in C++ In Object-Oriented Programming (OOP), the concept of polymorphism allows the same function name to behave differently depending on the type of object that calls it. In C++, this is mainly achieved through virtual functions and […]

Explain concepts of Class and Objects.

Q.1 Solution…. Q.1 Explain concepts of Class and Objects. Answer :-  Class and Objects in C++ Object-Oriented Programming (OOP) is one of the most powerful programming paradigms, and C++ is widely known as the first major programming language that fully supported OOP.Two of its most fundamental concepts are Class and Object. 1. Class in C++ […]