introduction to object oriented programming

14

Upload: kulari-lokuge

Post on 13-Jun-2015

449 views

Category:

Education


4 download

DESCRIPTION

Introduction to OOP with inheritance and Polymorphism, class concepts

TRANSCRIPT

Page 1: Introduction to Object Oriented Programming
Page 2: Introduction to Object Oriented Programming

I am a personI have a name which is KulariI have a surname LokugeI have a Birthday I have a height

I work at a University in MelbourneI drive to work about 15 km I write research papersI supervise projectsI play the piano I walk with my dog everyday

Page 3: Introduction to Object Oriented Programming

Name: Mike, Chalin, Mike, Salime, Irine, Isesak Water Victoria, Jakson, William, Mosses, John, Salina, Mosses, Nasa, Mervin, Gitida, Habats, Rita, John, Sarah, Jim, Joseph, Roset, Hamet, Rasberis, Geroge University year:Age:Height:

What are you good at?Playing sports?Cooking?Reading?Writing?

Page 4: Introduction to Object Oriented Programming

Name:Age:Height:

Activities:TalkReadWriteWalk

Name:Age:Height:

Activities:TalkReadWriteWalk

Page 5: Introduction to Object Oriented Programming
Page 6: Introduction to Object Oriented Programming

Person

Name:Age:Height:

Activities:TalkReadWriteWalk

Kulari

Sam

Peter

Page 7: Introduction to Object Oriented Programming

// smallobj.cpp // demonstrates a small, simple object#include <iostream> using namespace std; //////////////////////////////////////////////////// class smallobj               //declare a class    {     private:

      int somedata;          //class data public:     

void setdata(int d)    //member function to set data          { somedata = d; } void showdata()        //member function to display data        

  { cout << "Data is " << somedata << endl; }  

} ;//////////////////////////////////////////////////////////////// int main()    {    smallobj s1, s2;   //define two objects of class smallobj     s1.setdata(1066);  //call member function to set data    s2.setdata(1776);    s1.showdata();     //call member function to display data    s2.showdata();    return 0;    }

??

Page 8: Introduction to Object Oriented Programming

Private – generally data is hidden within the class so that it will be safe from accidental manipulations

Public - generally functions are public so that they can be accessed from outside the class

Is this a Rule? No

The data can be public and some functions can be private

Page 9: Introduction to Object Oriented Programming

Person

Lecturer Student Admin

Senior Junior Final First

Page 10: Introduction to Object Oriented Programming

Object-oriented languages like C++ enable you to create your own data types.

Why is it important? New user defined data types make

programs › easier to visualize and implement from designs.› reusable.› easy to modify and enhance new data types as

programs evolve and specifications change.› New data types let you create objects with

simple declarations.

Page 11: Introduction to Object Oriented Programming

An object is an instantiation of a data type.

Examples.› Person p;› Window w; › Window object Database ood;

Page 12: Introduction to Object Oriented Programming

Do you know what this is?

Yes No

Page 13: Introduction to Object Oriented Programming

3 + 5 45.1 + .5

What about this? +

+

+ +

Page 14: Introduction to Object Oriented Programming

Contact [email protected] LinkedIn: klokuge Website: http://kulari.weebly.com