Lecture 1.2
Lecture 1.2
Technology
Data Structures & Algorithm
Introduction
Wednesday
Student Advisory Hour
Thursday
Student Advisory Hour
Some Rules
– Raise your hand before asking any question and then
WAIT for the permission
– Never ever miss a class
– Never ever “sleep” in the class
– Never use mobile phones in the class
Dishonesty, Plagiarism
but you can not fool all of the people all of the
time.
Abraham Lincoln,
16th president of US (1809 - 1865)
General Overview
Introduction to
Computer Science
Computer
Programming
How to write software with the help of procedural and object oriented
programming?
Data Structures
How to efficiently utilize memory with the help of different data structures?
Algorithm
Analysis
• Reference
• https://drive.google.com/drive/folders/
1qwJisoVShTqJFPEeQdykY3mkGfj0YaWB?usp=sharing
Quiz-01
Composition
Consider the following implementation of the
student class:
Student
gpa : float
rollNo : int
name : char *
Student
gpa : float
rollNo : int String
name : String string : char *
Student(char * = NULL, int = 0,
float = 0.0); String()
Student(const Student &) SetString(char *) : void
GetName() const : String GetString() const : const char *
GetNamePtr() const : const char * ~String()
SetName(char *) : void …
~Student()
…
Composition
►Constructors of the sub-objects
are always executed before the
constructors of the master class
►Example:
Constructor for the sub-object name
is executed before the constructor of
Student
Composition
Now consider the following case:
String
name: char *
Student
String()
… String(char *)
name : String ~String()
birthDate : Date …
Student()
Student( char *, Date
const Date &, int, float)
SetName(char *) : void day: int
GetName() : char * Month: int
~Student() year: int
… …
Date()
Date(int,int,int)
Date(const Date &)
…
Aggregation
Composition vs. Aggregation
►Aggregation is a weak relationship
Room Chair
area : float …
chairs[50]:Chair *
Chair()
DoSomething() : void
Room(char *, int)
FoldChair() : bool
~Room()
UnFoldChair() : bool
FoldChair(int) : bool
~Chair()
…
…
Aggregation
►In aggregation, a pointer or reference to an object is
created inside a class
►The sub-object has a life that is NOT dependant
on the life of its master class
►e.g:
Chairs can be moved inside or outside at anytime
When Room is destroyed, the chairs may or may
not be destroyed