0% found this document useful (0 votes)
5 views5 pages

Object-Oriented Programming LAB # 6

The document outlines a lab experiment focused on C++ Operator Overloading, detailing objectives and assessment criteria for both lab conduct and report. It includes three specific tasks: overloading the * operator for matrix multiplication, the % operator for modulus operation, and the == and ! operators for string comparison. The conclusion emphasizes the benefits and considerations of using operator overloading in programming.

Uploaded by

Anus Babar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Object-Oriented Programming LAB # 6

The document outlines a lab experiment focused on C++ Operator Overloading, detailing objectives and assessment criteria for both lab conduct and report. It includes three specific tasks: overloading the * operator for matrix multiplication, the % operator for modulus operation, and the == and ! operators for string comparison. The conclusion emphasizes the benefits and considerations of using operator overloading in programming.

Uploaded by

Anus Babar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

BCE-2A OOP LAB

AIR UNIVERSITY

DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING


EXPERIMENT: 06

Lab Title: Operator Overloading in C++

Student Name:

Objectives:

This lab is made to develop student understanding related to C++ Operator Overloading.

LAB ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate
the results
Effective use of lab
equipment and follows
the lab safety rules

Total Marks: Obtained Marks:

LAB REPORT ASSESSMENT:

Excellent Good Average Satisfactory Unsatisfactory


Attributes
(5) (4) (3) (2) (1)

Data presentation

Experimental results

Conclusion

Total Marks: Obtained Marks:

Date: Signature:

Submitted To: Engr. Sidrish Ehsan


Date: 8-04-2025

Page | 1
BCE-2A OOP LAB

LABORATORY
EXPERIMENT NO.6

Lab Task 01:


Overload the * operator to multiply two matrices. Create a class Matrix with:
• A 2D array as a private data member.
• A constructor to initialize matrix elements.
• An overloaded * operator for matrix multiplication.
• A function to display the matrix.
• Implement matrix multiplication using the overloaded operator.

Page | 2
BCE-2A OOP LAB

Lab Task 02:

Implement a class Number that overloads the % operator to find the remainder when dividing two
numbers. Create a class Number with:
• Private data member value.
• A constructor to initialize the value.
• An overloaded % operator to perform modulus operation.
• A function to display the result.

Page | 3
BCE-2A OOP LAB

Lab Task 03:


Overload the “==” and “!” operator to compare two string objects. Create a class MyString with:
• A private character array or string data type.
• A constructor to initialize the string.
• An overloaded == operator to compare two strings and ! operator incase not equal.
• A function to display the string.

Page | 4
BCE-2A OOP LAB

CONCLUSION
• Operator overloading enhances the functionality of existing operators by allowing them to
work with user-defined data types, leading to more intuitive and readable code.
• It enables objects of custom classes to be manipulated using standard operators, simplifying
operations like addition, subtraction, and comparison.
• Proper implementation of operator overloading ensures that operators behave consistently and
logically, preventing potential confusion or errors in the code.
• While powerful, operator overloading should be used cautiously to avoid excessive complexity
and ensure that the code remains maintainable and understandable.

Page | 5

You might also like