introduction to object oriented programming
DESCRIPTION
Introduction to OOP with inheritance and Polymorphism, class conceptsTRANSCRIPT
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
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?
Name:Age:Height:
Activities:TalkReadWriteWalk
Name:Age:Height:
Activities:TalkReadWriteWalk
Person
Name:Age:Height:
Activities:TalkReadWriteWalk
Kulari
Sam
Peter
// 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; }
??
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
Person
Lecturer Student Admin
Senior Junior Final First
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.
An object is an instantiation of a data type.
Examples.› Person p;› Window w; › Window object Database ood;
Do you know what this is?
Yes No
3 + 5 45.1 + .5
What about this? +
+
+ +
Contact [email protected] LinkedIn: klokuge Website: http://kulari.weebly.com