Previous Lecture lect04 Next Lecture

Code from lecture

https://github.com/ucsb-cs24-w19-mirza/cs24-w19-lectures/tree/master/lec-04

Topics

Review of pointers and dynamic memory allocation

Operator overloading - Pages 63 - 80 in the book

We will start with a basic implementation of the point class from Chapter 2. We will then augment the class with binary operator functions. By overloading certain operators like ==, we can now write code as shown below:

point p1, p2;
if (p1 == p2){
  cout<<"Points are equal\n";
}

We will specifically discuss:

  1. Overloading binary comparison operators e.g. ==
  2. Overloading binary arithmetic operators e.g. +
  3. Overloading output and input operators e.g. » and «