Object Oriented Programming in C++

Practical 1: Function In OOPS

Write a function power() that takes a double value n and an int p, returning n raised to p. Use a default value of 2 for p to square n if omitted. Create a main() function to get user input and test power().

Execute →

Practical 2: Structure In OOPS

Create a Point structure with X and Y coordinates. Allow the user to input values for two points, compute their sum as a third point, and display the result.

Execute →

Practical 3: Switch Statement In OOPS

Create a four-function calculator that takes two numbers and an operator, performs the operation using a switch statement, and displays the result. After each calculation, ask if the user wants to continue (Y/N).

Execute →

Practical 4: Structure In OOPS

Create a phone structure to store a phone number's area code, exchange, and number separately. Initialize one variable and take user input for another. Then, display both numbers.

Execute →

Practical 5: Friend Function In OOPS

Create two classes, DM (meters & centimeters) and DB (feet & inches), to store distances. Implement a friend function to add a DM object with a DB object. The result can be stored in either DM or DB, based on the required unit. Display the result accordingly in meters & centimeters or feet & inches.

Execute →

Practical 6: Operator Overloading In OOPS

Create a Rational class with NUMERATOR and DENOMINATOR (double). Overload +, - and * operators.

Execute →

Practical 7: Polymorphism / Virtual Function In OOPS

Define a father class with a protected age and a virtual iam() function. Derive son and daughter classes, overriding iam() with appropriate messages. Implement constructors for both. Demonstrate polymorphism using pointers.

Execute →

Practical 8: File Handling In OOPS

Write a program that creates a binary file by reading the data for students from the terminal. The data includes roll number, name (max 30 characters), and marks.

Execute →

Practical 9: Inheritance In OOPS

Create a Date class to store year, month, and day. Define a base class for patient details (name, admission date, disease, discharge date) with functions to enter and display records. Derive a class to include age and list pediatric patients (age < 12).

Execute →

Practical 10: Function In OOPS

Create a tollbooth management system with functions payingCar(), nopayCar(), and display().

Execute →