




















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main topics in this course are object-orientation, objects and classes, overloading, inheritance, polymorphism, generic programming, exception handling, introduction to design patterns. This lecture includes: Pointer, Object, Static, Member, Data, Private, Array, Protected, Array, Function, Dynamic, Main, Return, Constructor, Destructor
Typology: Slides
1 / 28
This page cannot be seen from the preview
Don't miss anything!





















►
►
►
class Student{… public:
Studen();Student(char * aName);void setRollNo(int aNo); };
int main(){
Student obj;Student *ptr;ptr = &obj;ptr->setRollNo(10);return 0; }
Breakup of new Operation
►
Allocating space in memory Calling the appropriate constructor
Design a class date through which user must be ableto perform following operations
^
Get and set current day, month and year ^
Increment by x number of days, months and year ^
Set default date
►
This attribute must be declared a static member
class Date{
int day;int month;int year;static Date defaultDate; … };
►
class Date{… public:
void setDay(int aDay);int getDay() const;void addDay(int x);… … };
Constructors and Destructors in
Date.h
Date(int aDay = 0,
int aMonth= 0, int aYear= 0); ~Date(); //Destructor };
Implementation of Date Class
►
Date Date::defaultDate (07,3,2005);