Lab 10
Lab 10
CODE:
#include <iostream>
return a + b;
return a + b + c;
int main() {
// Example usage
std::cout << "Sum of two numbers: " << result1 << std::endl;
int result2 = sum(2, 4, 6); // Sum of three numbers
std::cout << "Sum of three numbers: " << result2 << std::endl;
return 0;
OUTPUT:
QUESTION NO. 2:
CODE:
#include <iostream>
#include <string>
class Employee {
protected:
std::string name;
public:
// Constructor
};
private:
std::string department;
public:
// Constructor
: Employee(name), department(department) {}
};
int main() {
emp.display();
// Creating a Manager object
mgr.display();
return 0;
OUTPUT:
QUESTION 3:
CODE:
#include <iostream>
class Student {
protected:
double gpa;
public:
// Constructor
return gpa;
};
public:
// Constructor
// For demonstration purposes, let's say we just add 0.5 to the GPA
};
int main() {
Student std(3.8);
return 0;
OUTPUT:
QUESTION 4:
CODE:
#include <iostream>
// Abstract base class Account
class Account {
public:
};
private:
double balance;
double interestRate;
public:
// Constructor
};
private:
double balance;
double transactionFee;
public:
// Constructor
};
int main() {
// Example usage
return 0;
OUTPUT:
CONCLUSION:
In Lab 101 , we learnt about inheritance of the class in which there is
one main base class while other classes are derived from it and public
data members of base class can be used in derived class .Also we
learnt about polymorphism and created class pointers and array.