Complete Oop Lab File 2
Complete Oop Lab File 2
Objective:
To implement a Matrix class in C++ using dynamic memory, constructors, a destructor, a copy
constructor, and assignment operator overloading.
Code:
Output:
Lab Experiment 3: Complex Number Class
Objective:
To create a Complex class in C++ that supports arithmetic operations, allows type conversions, and
displays complex numbers.
Code:
Output:
Lab Experiment 4: Custom Memory Allocation with new and delete
Objective:
To overload the new and delete operators in C++ for a custom memory allocation in a class.
Code:
Output:
Lab Experiment 5: Class Hierarchy for Inheritance Types
Objective:
To create a C++ class hierarchy that demonstrates different types of inheritance: single, multiple,
multilevel, and hierarchical inheritance.
Code:
Output:
Lab Experiment 6: Demonstrating Dynamic Polymorphism and RTTI
Objective:
To create a C++ test application that demonstrates dynamic polymorphism and Runtime Type
Identification (RTTI). This program will utilize base and derived classes to show polymorphic behavior
and identify object types at runtime.
Code:
Output:
Lab Experiment 7: Template for a Linked List Class in C++
Objective:
To create a template-based Linked List class in C++ that can store elements of any data type, with
methods to perform basic operations like adding, removing, and displaying nodes.
Code:
Output:
Lab Experiment 8: Templates for Standard Sorting Algorithms in C++
Objective:
To create template-based implementations of standard sorting algorithms, including Bubble Sort,
Insertion Sort, and Quick Sort in C++, allowing these algorithms to work with different data types.
Code:
Output:
Lab Experiment 9: Stack and Queue Classes with Exception Handling in
C++
Objective:
To implement Stack and Queue classes in C++ with exception handling to manage errors such as
overflow and underflow conditions.
Code:
Output:
Lab Experiment 10: Complex Number File Operations with Random
Generation in C++
Objective:
To create a C++ program that generates random complex numbers, writes them to a file in pairs with a
random operator between them, and reads the file line by line.
Code:
File Writing Program:
This program generates complex numbers in the format (a + bi), pairs them with an operator, and writes
them to a file.
Output:
This program creates a file with lines like:
And displays these lines on the console upon reading.