CISC 2200 Lecture Notes - Lecture 6: Operator Overloading, Memory Map

0 views1 pages
user avatar
Published on 4 Jul 2020
School
Fordham University
Department
Computer and Information Sciences
Course
CISC 2200
Professor
Review Notes
Operator Overloading
Friend function
Can access the private variables
Member function
Used for *, ++, !=
Parameter (const rational & n) const;
Drawing memory map
Scopes and lifetime
Static Variable
In a function, the lifetime is the program not just the function.
In a class, it shared by all instances of that classes
Topics for midterm
Friend functions and operator overloading
Member function operator overloading
Variable scope and lifetime
Pointer and arrays
Pointers and reference to pointers
Pointer dereferencing and pointer arithmetic
Unsorted List ADT
Dynamic variable allocation
Creating, modifying, and iterating through linked structures
BIG THREE
EX:
Write code to make pointer q points to the node that stores value 50. Note: you can assume that
such node exists.
Node *q = head;
while(q -> value != 50)
{
Q -> q -> next;
}
Expand the above code to make another pointer r to the node before the node(50). Note: if node
50 happens to be the first node, make rs value Null;
Node *q = head;
Node *r = NULL;
while(q -> value != 50)
{
Q -> q -> next;
}
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Document Summary

Review notes: operator overloading, friend function, can access the private variables, member function. Used for *, ++, !: parameter (const rational & n) const, drawing memory map, scopes and lifetime, static variable. In a function, the lifetime is the program not just the function. Write code to make pointer q points to the node that stores value 50. Note: you can assume that such node exists. Node *q = head; while(q -> value != 50) Expand the above code to make another pointer r to the node before the node(50). 50 happens to be the first node, make r"s value null; Node *r = null; while(q -> value != 50)