100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
CO2402 Advanced Programming with C++ Lecture 15 Notes $3.87   Add to cart

Class notes

CO2402 Advanced Programming with C++ Lecture 15 Notes

 8 views  0 purchase
  • Course
  • Institution

This document contains comprehensive notes from Lecture 15 of the CO2402 course on Advanced Programming with C++. The lecture covers the concepts of function and operator overloading, essential features in C++ that allow multiple functions or operators to have the same name with different parameter...

[Show more]

Preview 2 out of 5  pages

  • August 5, 2024
  • 5
  • 2023/2024
  • Class notes
  • Nicholas mitchell
  • All classes
  • Unknown
avatar-seller
CO2402: Advanced Programming
with C++ Lecture 15


Introduction to Overloading

1. Concept of Overloading

o Overloading refers to using the same name for more than one
operation or function. In C++, this includes function
overloading and operator overloading.

Example:




2. Difference Between Overloading and Overriding

o Overloading: Same name, different parameter types or
number of parameters.

o Overriding: Same name, same parameters in a base and
derived class, using the virtual keyword.

Operator Overloading

1. Definition and Syntax

o Operators can be overloaded to work with user-defined types,
such as classes. The syntax for overloading an operator
involves defining a function with the keyword operator
followed by the operator symbol.

Example:

, 2. Overloadable Operators

o Most operators in C++ can be overloaded, including
arithmetic operators (+, -, *, /), relational operators (==, <,
>), and more. However, certain operators, like . (member
access), :: (scope resolution), and ?: (ternary), cannot be
overloaded.

Example: The CTwoInts Class

1. Class Definition

o The CTwoInts class includes member variables mX and mY,
representing two integers. It demonstrates overloading
assignment and arithmetic operators.

Example:




2. Overloading the Assignment Operator (=)

o The assignment operator is overloaded to assign the values of
one CTwoInts object to another.

Example:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller BpoBpo. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $3.87. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

67096 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$3.87
  • (0)
  Add to cart