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 two classes `Alpha` and `Beta`, each with private data. Use a friend function to calculate and display the sum of their private data.
Create two classes `Alpha` and `Beta`, each with private data. Use a friend function to calculate and display the sum of their private data. SOLUTION…. C++ Friend Function Example #include <iostream> using namespace std; class Beta; // Forward declaration // Class Alpha class Alpha { private: int a; public: void input() { cout << “Enter […]
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 a base class `Shape`, and derive classes `Rectangle` and `Triangle`. Use functions to input dimensions and calculate area of each shape.
Create a base class `Shape`, and derive classes `Rectangle` and `Triangle`. Use functions to input dimensions and calculate area of each shape. SOLUTION…. Pure Virtual Function Example in C++ #include <iostream> using namespace std; // Base class class Shape { public: virtual void input() = 0; // Pure virtual function virtual void area() = 0; […]
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 […]
What is operator overloading? Write different rules to overload operators. Also, explain Operator overloading with an example.
ASSIGNMENT ASSIGNMENT ASSIGNMENT Q.1 Explain Codd’s Rules. Answer :- Codd’s rules, proposed by Dr. Edgar F. Codd in 1985, serve as a benchmark for evaluating whether a database management system (DBMS) is truly relational. Codd originally defined 12 rules, including a rule 0, which collectively outline the characteristics a system must exhibit to qualify as […]
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++ […]
Write a Program to demonstrate multilevel Inheritance. Create class `A` with integer `x`, class `B` derives from `A` and has integer `y`, class `C` derives from `B` and calculates product of `x` and `y`.
Write a Program to demonstrate multilevel Inheritance. Create class `A` with integer `x`, class `B` derives from `A` and has integer `y`, class `C` derives from `B` and calculates product of `x` and `y`. SOLUTION….
