SlideShare a Scribd company logo
1 of 35
C++ OOP :: Class Structure 29/09/2009 1 Hadziq Fabroyir - Informatics ITS
C++ Structures:  Classes In C++, the concept of structure has been generalized in an object-oriented sense: classes are types representing groups of similar instances each instance has certain fields that define it (instance variables) instances also have functions that can be applied to them (represented as function fields) -- called methods the programmer can limit access to parts of the class (to only those functions that need to know about the internals) 29/09/2009 2 Hadziq Fabroyir - Informatics ITS
A Motivating Example You declare a simple structure: struct Robot {   float locX;   float locY;   float facing; }; Robot r1; What if you never want locX or locY to be negative ? Someone unaware of your restriction could set: r1.locX = -5; and you have a problem ! 29/09/2009 3 Hadziq Fabroyir - Informatics ITS
General Class Definition in C++ class ClassName { access_modifier1: field11_definition; field12_definition;     … access_modifer2: field21_definition; field22_definition;   … }; ClassName is a new type (just as if declared as struct with typedef in C) Possible access modifiers:  public private Protected Fields can be variables (as in C structures) or functions 29/09/2009 4 Hadziq Fabroyir - Informatics ITS
A Simple Class class Robot {   public:     float getX() { return locX; }     float getY() { return locY; }     float getFacing() { return facing; }     void setFacing(float f) { facing = f; }     void setLocation(float x, float y); private:     float locX;     float locY;     float facing; }; 29/09/2009 5 Hadziq Fabroyir - Informatics ITS
private Access Modifier Fields marked as private can only be accessed by functions that are part of that class In the Robot class, locX, locY, and facing are private float fields, these fields can only be accessed by functions that are in class Robot (getX, getY, getFacing, setFacing, setLocation) Example: void useRobot() {   Robot r1;   r1.locX = -5; // Error 29/09/2009 6 Hadziq Fabroyir - Informatics ITS
publicAccess Modifier Fields marked as public can be accessed by anyone In the Robot class, the methods getX, getY, etc. are public these functions can be called by anyone Example: void useRobot() {   Robot r1;   r1.setLocation(-5,-5); // Legal to call 29/09/2009 7 Hadziq Fabroyir - Informatics ITS
structVS class In C++ struct and class can be used interchangeably to create a class with one exception What if we forget to put an access modifier before the first field? struct Robot {    OR    class Robot {   float locX;             float locX; In a class, until an access modifer is supplied, the fields are assumed to beprivate In a struct, the fields are assumed to bepublic 29/09/2009 8 Hadziq Fabroyir - Informatics ITS
What about protected? C++ allows users to create classes based on other classes: a FordCar class based on a general Car class idea: the general Car class has fields (variables and functions that describe all cars) the FordCar class then uses the fields from the general Car class and adds fields specific to FordCars done with inheritance public fields are inherited (as public) private fields are not inherited protected fields are like private, but can be inherited 29/09/2009 9 Hadziq Fabroyir - Informatics ITS
Class Methods Functions associated with a class are declared in one of two ways: ReturnType FuncName(params) { code } function is both declared and defined (code provided) ReturnType FuncName(params); function is merely declared, we must still define the body of the function separately To call a method we use the . form: classinstance.FuncName(args); FuncName is a field just like any other field in the structured variable classinstance 29/09/2009 10 Hadziq Fabroyir - Informatics ITS
Defined Methods class Robot {   public: float getX() { return locX; } }; Robot r1; The function getX is defined as part of class Robot To call this method: cout << r1.getX() << endl; // prints r1’s locX 29/09/2009 11 Hadziq Fabroyir - Informatics ITS
Defining Methods Separately For methods  that are declared but not defined in the class we need to provide a separate definition To define the method, you define it as any other function, except that the name of the function is ClassName::FuncName :: is the scope resolution operator, it allows us to refer to parts of a class or structure 29/09/2009 12 Hadziq Fabroyir - Informatics ITS
A Simple Class class Robot {   public:     void setLocation(float x, float y);   private:     float locX;     float locY;     float facing; }; void Robot::setLocation(float x, float y) {   if ((x < 0.0) || (y < 0.0))     cout << “Illegal location!!” << endl;   else {     locX = x;     locY = y;   } } 29/09/2009 13 Hadziq Fabroyir - Informatics ITS
Types of Class Methods  Generally we group class methods into three broad categories: accessors - allow us to access the fields of a class instance (examples: getX, getY, getFacing), accessors do not change the fields of a class instance mutators - allow us to change the fields of a class instance (examples: setLocation, setFacing), mutators do change the fields of a class instance manager functions- specific functions (constructors, destructors) that deal with initializing and destroying class instances (more in a bit) 29/09/2009 14 Hadziq Fabroyir - Informatics ITS
Accessors & Mutators Why do we bother with accessors and mutators? Why provide getX()?? Why not just make the locX field publicly available? By restricting access using accessors and mutators we make it possible to change the underlying details regarding a class without changing how people who use that class interact with the class Example: what if I changed the robot representation so that we no longer store locX and locY, instead we use polar coordinates (distance and angle to location)? If locX is a publicly available field that people have been accessing it, removing it will affect their code If users interact using only accessors and mutators then we can change things without affecting their code 29/09/2009 15 Hadziq Fabroyir - Informatics ITS
Rewritten Robot Class class Robot {   public:     float getX() { return dist * cos(ang); }     float getY() { return dist * sin(ang); }     void setLocation(float x, float y);   private: float dist;     float ang; }; void Robot::setLocation(float x, float y) {   if ((x < 0.0) || (y < 0.0))     cout << “Illegal location!!” << endl;   else { dist = sqrt(x * x + y * y);     ang = atan2(y,x);   } } 29/09/2009 16 Hadziq Fabroyir - Informatics ITS
Object-Oriented Idea Declare implementation-specific fields of class to be private Provide public accessor and mutator methods that allow other users to connect to the fields of the class often provide an accessor and mutator for each instance variable that lets you get the current value of that variable and set the current value of that variable to change implementation, make sure accessors and mutators still provide users what they expect 29/09/2009 17 Hadziq Fabroyir - Informatics ITS
Static Instance Variables C++ classes may also contain, static instance fields -- a single field shared by all members of a class Often used when declaring class constants (since you generally only need one copy of a constant) To make a field static, add the static keyword in front of the field can refer to the field like any other field (but remember, everybody shares one copy) static variables are also considered to be global, you can refer to them without an instance static fields can be initialized (unlike other fields) 29/09/2009 18 Hadziq Fabroyir - Informatics ITS
Static Fields Example class Robot {   public: static int numRobots = 0;     static const float minX = 0.0;     static const float maxX = 100.0;     void initializeRobot() { numRobots++;     }     void setLocation(float x, float y); } void Robot::setLocation(float x, float y) {   if ((x < minX) || (x > maxX))   … } 29/09/2009 19 Hadziq Fabroyir - Informatics ITS
Static Fields as Global Variables One can examine public static fields of a class outside of that class using the form: ClassName::StaticFieldName Example: void main() {   Robot r1, r2;   r1.initializeRobot();   r2.initializeRobot();   cout << Robot::numRobots << “ robots.”; 29/09/2009 20 Hadziq Fabroyir - Informatics ITS
The Need for Manager Functions To make the previous program work we have to explicitly call the routine initializeRobot, wouldn’t it be nice to have a routine that is automatically used to initialize an instance -- C++ does C++ provides for the definition of manager functions to deal with certain situations: constructors (ctor) - used to set up new instances default - called for a basic instance copy - called when a copy of an instance is made (assignment) other - for other construction situations destructors (dtor) - used when an instance is removed 29/09/2009 21 Hadziq Fabroyir - Informatics ITS
When Managers Called void main() {   Robot r1;  // default ctor (on r1)    Robot r2;  // default ctor (on r2)   Robot* r3ptr;   r3ptr = new Robot; // default ctor on     // Robot object r3ptr points to   r2 = r1;  // copy ctor   delete r3ptr; // dtor } // dtor (on r1 and r2) when main ends 29/09/2009 22 Hadziq Fabroyir - Informatics ITS
The Default Constructor (ctor) A default constructor has no arguments, it is called when a new instance is created C++ provides a default ctor that initializes all fields to 0 To write your own, add following to your class: class MyClass {   public:     … MyClass() {   // repeat class name, no code here   // return type     } } 29/09/2009 23 Hadziq Fabroyir - Informatics ITS
Example Default ctor class Robot {   public:     static int numRobots = 0; Robot() {       numRobots++;       locX = 0.0;       locY = 0.0;       facing = 3.1415 / 2;     }   private:     float locX;     float locY;     float facing; } 29/09/2009 24 Hadziq Fabroyir - Informatics ITS
Destructor (dtor) A destructor is normally not critical, but if your class allocates space on the heap, it is useful to deallocate that space before the object is destroyed C++ provides a default dtor that does nothing can only have one dtor To write your own, add following to your class: class MyClass {   public:     … ~MyClass() {    code here     } } 29/09/2009 25 Hadziq Fabroyir - Informatics ITS
Example dtor class Robot {   public:     char *robotName; Robot() {       robotName = 0;     }     void setRobotName(char *name) {       robotName = new char[strlen(name)+1];       strcpy(robotName,name);     } ~Robot() {       delete [] robotName;     } } 29/09/2009 26 Hadziq Fabroyir - Informatics ITS
The Copy ctor A copy constructor is used when we need a special method for making a copy of an instance example, if one instance has a pointer to heap-allocated space, important to allocate its own copy (otherwise, both point to the same thing) To write your own, add following to your class: class MyClass {   public:     … MyClass(const MyClass& obj) { code here     } } 29/09/2009 27 Hadziq Fabroyir - Informatics ITS
Example Copy ctor class Robot {   public:     char *robotName;     void setRobotName(char *name) {       robotName = new char[strlen(name)+1];       strcpy(robotName,name);     } Robot(const Robot& obj) {       robotName = new char[strlen(obj.robotName)+1];       strcpy(robotName,obj.robotName);     } } 29/09/2009 28 Hadziq Fabroyir - Informatics ITS
Other ctors It is often useful to provide constructors that allow the user to provide arguments in order to initialize arguments Form is similar to the copy ctor, except parameters are chosen by programmer: class MyClass {   public;     … MyClass(parameters) { code here     } } 29/09/2009 29 Hadziq Fabroyir - Informatics ITS
Example ctor class Robot {   public:     Robot(float x, float y, float face) {       locX = x;       locY = y;       facing = face;     } } calling:   Robot r1(5.0,5.0,1.5);   Robot r2(5.0,10.0,0.0);   Robot* rptr;   rptr = new Robot(10.0,5.0,-1.5); 29/09/2009 30 Hadziq Fabroyir - Informatics ITS
A Combination ctor Can combine a ctor that requires arguments with the default ctor using default values: class Robot {   public: Robot(float x = 0.0, float y = 0.0,            float face = 1.57075) {       locX = x; locY = y; facing = face;     } } calling:   Robot r1;   // ctor called with default args   Robot r2(); // ctor called with default args   Robot r3(5.0); // ctor called with x = 5.0 Robot r4(5.0,5.0); // ctor called with x,y = 5.0   …  29/09/2009 31 Hadziq Fabroyir - Informatics ITS
Hiding the Default ctor Sometimes we want to make sure that the user gives initial values for some fields, and we don’t want them to use the default ctor To accomplish this we declare an appropriate ctor to be used in creating instances of the class in the public area, then we put the default ctor in the private area (where it cannot be called) 29/09/2009 32 Hadziq Fabroyir - Informatics ITS
Example ctor class Robot {   public: Robot(float x, float y, float face) {       locX = x;       locY = y;       facing = face;     }   private:     Robot() {} } calling:   Robot r1(5.0,5.0,1.5);   Robot r2;  // ERROR, attempts to call default ctor 29/09/2009 33 Hadziq Fabroyir - Informatics ITS
For your practice … Exercise 9.5  Complex Class Properties:  float realPart, float imaginaryPart  Method (Mutators): Complex addBy(Complex), ComplexSubstractBy(Complex) Lab Session for upper order (Senin, 15.00-17.00) Lab Session for lower order (Senin, 19.00-21.00) Please provide: 	the softcopy(send it by email – deadline Sunday 23:59) the hardcopy(bring it when attending the lab session) 29/09/2009 Hadziq Fabroyir - Informatics ITS 34
☺~ Next: C++ OOP :: Overloading ~☺ [ 35 ] Hadziq Fabroyir - Informatics ITS 29/09/2009

More Related Content

What's hot

Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Geeks Anonymes
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and OperatorsSunil OS
 
Operator overloading in C++
Operator overloading in C++Operator overloading in C++
Operator overloading in C++Ilio Catallo
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Liju Thomas
 
Tutconstructordes
TutconstructordesTutconstructordes
TutconstructordesNiti Arora
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Kamlesh Makvana
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpprajshreemuthiah
 
Virtual function
Virtual functionVirtual function
Virtual functionharman kaur
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++Jay Patel
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructorsVineeta Garg
 

What's hot (20)

Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
 
C++ Programming
C++ ProgrammingC++ Programming
C++ Programming
 
JAVA Variables and Operators
JAVA Variables and OperatorsJAVA Variables and Operators
JAVA Variables and Operators
 
Operator overloading in C++
Operator overloading in C++Operator overloading in C++
Operator overloading in C++
 
Constructor
ConstructorConstructor
Constructor
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++Abstract Base Class and Polymorphism in C++
Abstract Base Class and Polymorphism in C++
 
Tutconstructordes
TutconstructordesTutconstructordes
Tutconstructordes
 
Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function Virtual function in C++ Pure Virtual Function
Virtual function in C++ Pure Virtual Function
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp
 
Introduction to C++
Introduction to C++Introduction to C++
Introduction to C++
 
Virtual function
Virtual functionVirtual function
Virtual function
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
Constructor in c++
Constructor in c++Constructor in c++
Constructor in c++
 
Virtual Functions
Virtual FunctionsVirtual Functions
Virtual Functions
 
C++11
C++11C++11
C++11
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
 

Viewers also liked

DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Anwar Ul Haq
 
Function class in c++
Function class in c++Function class in c++
Function class in c++Kumar
 
Pemrograman C++ - Operasi Berkas
Pemrograman C++ - Operasi BerkasPemrograman C++ - Operasi Berkas
Pemrograman C++ - Operasi BerkasKuliahKita
 
Sd pertemuan 3 & 4 (edited)
Sd   pertemuan 3 & 4 (edited)Sd   pertemuan 3 & 4 (edited)
Sd pertemuan 3 & 4 (edited)biedoen
 
Sd pertemuan 5 & 6
Sd   pertemuan 5 & 6Sd   pertemuan 5 & 6
Sd pertemuan 5 & 6biedoen
 
Class dan object
Class dan objectClass dan object
Class dan objectHardini_HD
 
Struktur data pertemuan 1 & 2
Struktur data   pertemuan 1 & 2Struktur data   pertemuan 1 & 2
Struktur data pertemuan 1 & 2biedoen
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator OverloadingHadziq Fabroyir
 
Algoritma dan Struktur Data - Konstruktor dan Destruktor
Algoritma dan Struktur Data - Konstruktor dan DestruktorAlgoritma dan Struktur Data - Konstruktor dan Destruktor
Algoritma dan Struktur Data - Konstruktor dan DestruktorKuliahKita
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseoJinTaek Seo
 
Predavanja 06 Konstruktori i destruktori
Predavanja 06  Konstruktori i destruktoriPredavanja 06  Konstruktori i destruktori
Predavanja 06 Konstruktori i destruktoriGoran Igaly
 
9.double linked list circular
9.double linked list circular9.double linked list circular
9.double linked list circularHitesh Wagle
 

Viewers also liked (20)

OOP C++
OOP C++OOP C++
OOP C++
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
C++ Inheritance
C++ InheritanceC++ Inheritance
C++ Inheritance
 
Object Oriented Programming lecture 1
Object Oriented Programming lecture 1Object Oriented Programming lecture 1
Object Oriented Programming lecture 1
 
Lecture 1 oop
Lecture 1 oopLecture 1 oop
Lecture 1 oop
 
oop Lecture 3
oop Lecture 3oop Lecture 3
oop Lecture 3
 
Function class in c++
Function class in c++Function class in c++
Function class in c++
 
Pemrograman C++ - Operasi Berkas
Pemrograman C++ - Operasi BerkasPemrograman C++ - Operasi Berkas
Pemrograman C++ - Operasi Berkas
 
Sd pertemuan 3 & 4 (edited)
Sd   pertemuan 3 & 4 (edited)Sd   pertemuan 3 & 4 (edited)
Sd pertemuan 3 & 4 (edited)
 
Sd pertemuan 5 & 6
Sd   pertemuan 5 & 6Sd   pertemuan 5 & 6
Sd pertemuan 5 & 6
 
Class dan object
Class dan objectClass dan object
Class dan object
 
Struktur data pertemuan 1 & 2
Struktur data   pertemuan 1 & 2Struktur data   pertemuan 1 & 2
Struktur data pertemuan 1 & 2
 
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading#OOP_D_ITS - 5th - C++ Oop Operator Overloading
#OOP_D_ITS - 5th - C++ Oop Operator Overloading
 
Linked List
Linked ListLinked List
Linked List
 
Algoritma dan Struktur Data - Konstruktor dan Destruktor
Algoritma dan Struktur Data - Konstruktor dan DestruktorAlgoritma dan Struktur Data - Konstruktor dan Destruktor
Algoritma dan Struktur Data - Konstruktor dan Destruktor
 
02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo02 linked list_20160217_jintaekseo
02 linked list_20160217_jintaekseo
 
Predavanja 06 Konstruktori i destruktori
Predavanja 06  Konstruktori i destruktoriPredavanja 06  Konstruktori i destruktori
Predavanja 06 Konstruktori i destruktori
 
9.double linked list circular
9.double linked list circular9.double linked list circular
9.double linked list circular
 
Stack atau tumpukan
Stack atau tumpukanStack atau tumpukan
Stack atau tumpukan
 

Similar to #OOP_D_ITS - 4th - C++ Oop And Class Structure

Generic Synchronization Policies in C++
Generic Synchronization Policies in C++Generic Synchronization Policies in C++
Generic Synchronization Policies in C++Ciaran McHale
 
Mca 2nd sem u-2 classes & objects
Mca 2nd  sem u-2 classes & objectsMca 2nd  sem u-2 classes & objects
Mca 2nd sem u-2 classes & objectsRai University
 
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsBca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsRai University
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstractionIntro C# Book
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - TemplateHadziq Fabroyir
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop InheritanceHadziq Fabroyir
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C SharpHarman Bajwa
 
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...Igalia
 
Csharp4 objects and_types
Csharp4 objects and_typesCsharp4 objects and_types
Csharp4 objects and_typesAbed Bukhari
 
IAT334-Lec06-OOTutorial.pptx
IAT334-Lec06-OOTutorial.pptxIAT334-Lec06-OOTutorial.pptx
IAT334-Lec06-OOTutorial.pptxssuseraae9cd
 
Java design patterns
Java design patternsJava design patterns
Java design patternsShawn Brito
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4007laksh
 

Similar to #OOP_D_ITS - 4th - C++ Oop And Class Structure (20)

Generic Synchronization Policies in C++
Generic Synchronization Policies in C++Generic Synchronization Policies in C++
Generic Synchronization Policies in C++
 
Mca 2nd sem u-2 classes & objects
Mca 2nd  sem u-2 classes & objectsMca 2nd  sem u-2 classes & objects
Mca 2nd sem u-2 classes & objects
 
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsBca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objects
 
Intake 38 4
Intake 38 4Intake 38 4
Intake 38 4
 
Idiomatic C++
Idiomatic C++Idiomatic C++
Idiomatic C++
 
Android code convention
Android code conventionAndroid code convention
Android code convention
 
20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction20.4 Java interfaces and abstraction
20.4 Java interfaces and abstraction
 
#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template#OOP_D_ITS - 9th - Template
#OOP_D_ITS - 9th - Template
 
#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance#OOP_D_ITS - 6th - C++ Oop Inheritance
#OOP_D_ITS - 6th - C++ Oop Inheritance
 
C++ oop
C++ oopC++ oop
C++ oop
 
Reflection in C Sharp
Reflection in C SharpReflection in C Sharp
Reflection in C Sharp
 
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
Implementing one feature set in two JavaScript engines (Web Engines Hackfest ...
 
Ocl 09
Ocl 09Ocl 09
Ocl 09
 
Csharp4 objects and_types
Csharp4 objects and_typesCsharp4 objects and_types
Csharp4 objects and_types
 
COM Introduction
COM IntroductionCOM Introduction
COM Introduction
 
IAT334-Lec06-OOTutorial.pptx
IAT334-Lec06-OOTutorial.pptxIAT334-Lec06-OOTutorial.pptx
IAT334-Lec06-OOTutorial.pptx
 
Java design patterns
Java design patternsJava design patterns
Java design patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4
 

More from Hadziq Fabroyir

An Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld DeviceAn Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld DeviceHadziq Fabroyir
 
在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發Hadziq Fabroyir
 
NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)Hadziq Fabroyir
 
律法保護的五件事
律法保護的五件事律法保護的五件事
律法保護的五件事Hadziq Fabroyir
 
Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話Hadziq Fabroyir
 
Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西Hadziq Fabroyir
 
Pelajaran 3 第三課 • Transportasi 交通
Pelajaran 3 第三課 • Transportasi 交通Pelajaran 3 第三課 • Transportasi 交通
Pelajaran 3 第三課 • Transportasi 交通Hadziq Fabroyir
 
Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳Hadziq Fabroyir
 
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹Hadziq Fabroyir
 
Living in Taiwan for Dummies
Living in Taiwan for DummiesLiving in Taiwan for Dummies
Living in Taiwan for DummiesHadziq Fabroyir
 
How to Select Course at NTUST
How to Select Course at NTUSTHow to Select Course at NTUST
How to Select Course at NTUSTHadziq Fabroyir
 
NTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students OrientationNTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students OrientationHadziq Fabroyir
 
NTUST Course Selection - How to
NTUST Course Selection - How toNTUST Course Selection - How to
NTUST Course Selection - How toHadziq Fabroyir
 
#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class DiagramHadziq Fabroyir
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting StartedHadziq Fabroyir
 
#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And ReferencesHadziq Fabroyir
 
#OOP_D_ITS - 3rd - Migration From C To C++
#OOP_D_ITS - 3rd - Migration From C To C++#OOP_D_ITS - 3rd - Migration From C To C++
#OOP_D_ITS - 3rd - Migration From C To C++Hadziq Fabroyir
 
#OOP_D_ITS - 1st - Introduction To Object Oriented Programming
#OOP_D_ITS - 1st - Introduction To Object Oriented Programming#OOP_D_ITS - 1st - Introduction To Object Oriented Programming
#OOP_D_ITS - 1st - Introduction To Object Oriented ProgrammingHadziq Fabroyir
 

More from Hadziq Fabroyir (20)

An Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld DeviceAn Immersive Map Exploration System Using Handheld Device
An Immersive Map Exploration System Using Handheld Device
 
在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發在不同尺度遙現系統中具空間感知特性的使用者介面開發
在不同尺度遙現系統中具空間感知特性的使用者介面開發
 
NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)NTUST Course Selection (Revision: Fall 2016)
NTUST Course Selection (Revision: Fall 2016)
 
律法保護的五件事
律法保護的五件事律法保護的五件事
律法保護的五件事
 
Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話Pelajaran 5 第五課 • Telepon 給打電話
Pelajaran 5 第五課 • Telepon 給打電話
 
Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西Pelajaran 4 第四課 • Belanja 買東西
Pelajaran 4 第四課 • Belanja 買東西
 
Pelajaran 3 第三課 • Transportasi 交通
Pelajaran 3 第三課 • Transportasi 交通Pelajaran 3 第三課 • Transportasi 交通
Pelajaran 3 第三課 • Transportasi 交通
 
Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳Pelajaran 2 第二課 • Di Restoran 在餐廳
Pelajaran 2 第二課 • Di Restoran 在餐廳
 
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
Pelajaran 1 第一課 • Perkenalan Diri 自我介紹
 
Living in Taiwan for Dummies
Living in Taiwan for DummiesLiving in Taiwan for Dummies
Living in Taiwan for Dummies
 
How to Select Course at NTUST
How to Select Course at NTUSTHow to Select Course at NTUST
How to Select Course at NTUST
 
NTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students OrientationNTUST-IMSA • International Students Orientation
NTUST-IMSA • International Students Orientation
 
NTUST Course Selection - How to
NTUST Course Selection - How toNTUST Course Selection - How to
NTUST Course Selection - How to
 
Brain Battle Online
Brain Battle OnlineBrain Battle Online
Brain Battle Online
 
Manajemen Waktu
Manajemen WaktuManajemen Waktu
Manajemen Waktu
 
#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram#OOP_D_ITS - 8th - Class Diagram
#OOP_D_ITS - 8th - Class Diagram
 
#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started#OOP_D_ITS - 2nd - C++ Getting Started
#OOP_D_ITS - 2nd - C++ Getting Started
 
#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References#OOP_D_ITS - 3rd - Pointer And References
#OOP_D_ITS - 3rd - Pointer And References
 
#OOP_D_ITS - 3rd - Migration From C To C++
#OOP_D_ITS - 3rd - Migration From C To C++#OOP_D_ITS - 3rd - Migration From C To C++
#OOP_D_ITS - 3rd - Migration From C To C++
 
#OOP_D_ITS - 1st - Introduction To Object Oriented Programming
#OOP_D_ITS - 1st - Introduction To Object Oriented Programming#OOP_D_ITS - 1st - Introduction To Object Oriented Programming
#OOP_D_ITS - 1st - Introduction To Object Oriented Programming
 

Recently uploaded

Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...CALL GIRLS
 
Call Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort Service
Call Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort ServiceCall Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort Service
Call Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort Serviceparulsinha
 
Call Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night EnjoyCall Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night Enjoybabeytanya
 
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...narwatsonia7
 
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...narwatsonia7
 
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore EscortsCall Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escortsvidya singh
 
Call Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night EnjoyCall Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night Enjoybabeytanya
 
Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...
Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...
Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...Miss joya
 
CALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune) Girls Service
CALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune)  Girls ServiceCALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune)  Girls Service
CALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune) Girls ServiceMiss joya
 
Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...
Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...
Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...Miss joya
 
Artifacts in Nuclear Medicine with Identifying and resolving artifacts.
Artifacts in Nuclear Medicine with Identifying and resolving artifacts.Artifacts in Nuclear Medicine with Identifying and resolving artifacts.
Artifacts in Nuclear Medicine with Identifying and resolving artifacts.MiadAlsulami
 
Bangalore Call Girl Whatsapp Number 100% Complete Your Sexual Needs
Bangalore Call Girl Whatsapp Number 100% Complete Your Sexual NeedsBangalore Call Girl Whatsapp Number 100% Complete Your Sexual Needs
Bangalore Call Girl Whatsapp Number 100% Complete Your Sexual NeedsGfnyt
 
CALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune) Girls Service
CALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune)  Girls ServiceCALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune)  Girls Service
CALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune) Girls ServiceMiss joya
 
Russian Escorts Girls Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls Delhi
Russian Escorts Girls  Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls DelhiRussian Escorts Girls  Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls Delhi
Russian Escorts Girls Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls DelhiAlinaDevecerski
 
VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...
VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...
VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...Miss joya
 
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls AvailableVip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls AvailableNehru place Escorts
 
VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...
VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...
VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...Neha Kaur
 
Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...
Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...
Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...Call Girls in Nagpur High Profile
 
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...Garima Khatri
 

Recently uploaded (20)

Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
Call Girls Service Surat Samaira ❤️🍑 8250192130 👄 Independent Escort Service ...
 
Call Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort Service
Call Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort ServiceCall Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort Service
Call Girls Service In Shyam Nagar Whatsapp 8445551418 Independent Escort Service
 
Call Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night EnjoyCall Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Panvel Mumbai📲 9833363713 💞 Full Night Enjoy
 
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...High Profile Call Girls Coimbatore Saanvi☎️  8250192130 Independent Escort Se...
High Profile Call Girls Coimbatore Saanvi☎️ 8250192130 Independent Escort Se...
 
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...Bangalore Call Girls Nelamangala Number 7001035870  Meetin With Bangalore Esc...
Bangalore Call Girls Nelamangala Number 7001035870 Meetin With Bangalore Esc...
 
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore EscortsCall Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
Call Girls Horamavu WhatsApp Number 7001035870 Meeting With Bangalore Escorts
 
Call Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night EnjoyCall Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night Enjoy
Call Girl Number in Vashi Mumbai📲 9833363713 💞 Full Night Enjoy
 
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
Russian Call Girls in Delhi Tanvi ➡️ 9711199012 💋📞 Independent Escort Service...
 
Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...
Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...
Low Rate Call Girls Pune Esha 9907093804 Short 1500 Night 6000 Best call girl...
 
CALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune) Girls Service
CALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune)  Girls ServiceCALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune)  Girls Service
CALL ON ➥9907093804 🔝 Call Girls Baramati ( Pune) Girls Service
 
Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...
Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...
Call Girls Service Pune Vaishnavi 9907093804 Short 1500 Night 6000 Best call ...
 
Artifacts in Nuclear Medicine with Identifying and resolving artifacts.
Artifacts in Nuclear Medicine with Identifying and resolving artifacts.Artifacts in Nuclear Medicine with Identifying and resolving artifacts.
Artifacts in Nuclear Medicine with Identifying and resolving artifacts.
 
Bangalore Call Girl Whatsapp Number 100% Complete Your Sexual Needs
Bangalore Call Girl Whatsapp Number 100% Complete Your Sexual NeedsBangalore Call Girl Whatsapp Number 100% Complete Your Sexual Needs
Bangalore Call Girl Whatsapp Number 100% Complete Your Sexual Needs
 
CALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune) Girls Service
CALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune)  Girls ServiceCALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune)  Girls Service
CALL ON ➥9907093804 🔝 Call Girls Hadapsar ( Pune) Girls Service
 
Russian Escorts Girls Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls Delhi
Russian Escorts Girls  Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls DelhiRussian Escorts Girls  Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls Delhi
Russian Escorts Girls Nehru Place ZINATHI 🔝9711199012 ☪ 24/7 Call Girls Delhi
 
VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...
VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...
VIP Call Girls Pune Vrinda 9907093804 Short 1500 Night 6000 Best call girls S...
 
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls AvailableVip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
Vip Call Girls Anna Salai Chennai 👉 8250192130 ❣️💯 Top Class Girls Available
 
VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...
VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...
VIP Russian Call Girls in Varanasi Samaira 8250192130 Independent Escort Serv...
 
Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...
Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...
Book Paid Powai Call Girls Mumbai 𖠋 9930245274 𖠋Low Budget Full Independent H...
 
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
VIP Mumbai Call Girls Hiranandani Gardens Just Call 9920874524 with A/C Room ...
 

#OOP_D_ITS - 4th - C++ Oop And Class Structure

  • 1. C++ OOP :: Class Structure 29/09/2009 1 Hadziq Fabroyir - Informatics ITS
  • 2. C++ Structures: Classes In C++, the concept of structure has been generalized in an object-oriented sense: classes are types representing groups of similar instances each instance has certain fields that define it (instance variables) instances also have functions that can be applied to them (represented as function fields) -- called methods the programmer can limit access to parts of the class (to only those functions that need to know about the internals) 29/09/2009 2 Hadziq Fabroyir - Informatics ITS
  • 3. A Motivating Example You declare a simple structure: struct Robot { float locX; float locY; float facing; }; Robot r1; What if you never want locX or locY to be negative ? Someone unaware of your restriction could set: r1.locX = -5; and you have a problem ! 29/09/2009 3 Hadziq Fabroyir - Informatics ITS
  • 4. General Class Definition in C++ class ClassName { access_modifier1: field11_definition; field12_definition; … access_modifer2: field21_definition; field22_definition; … }; ClassName is a new type (just as if declared as struct with typedef in C) Possible access modifiers: public private Protected Fields can be variables (as in C structures) or functions 29/09/2009 4 Hadziq Fabroyir - Informatics ITS
  • 5. A Simple Class class Robot { public: float getX() { return locX; } float getY() { return locY; } float getFacing() { return facing; } void setFacing(float f) { facing = f; } void setLocation(float x, float y); private: float locX; float locY; float facing; }; 29/09/2009 5 Hadziq Fabroyir - Informatics ITS
  • 6. private Access Modifier Fields marked as private can only be accessed by functions that are part of that class In the Robot class, locX, locY, and facing are private float fields, these fields can only be accessed by functions that are in class Robot (getX, getY, getFacing, setFacing, setLocation) Example: void useRobot() { Robot r1; r1.locX = -5; // Error 29/09/2009 6 Hadziq Fabroyir - Informatics ITS
  • 7. publicAccess Modifier Fields marked as public can be accessed by anyone In the Robot class, the methods getX, getY, etc. are public these functions can be called by anyone Example: void useRobot() { Robot r1; r1.setLocation(-5,-5); // Legal to call 29/09/2009 7 Hadziq Fabroyir - Informatics ITS
  • 8. structVS class In C++ struct and class can be used interchangeably to create a class with one exception What if we forget to put an access modifier before the first field? struct Robot { OR class Robot { float locX; float locX; In a class, until an access modifer is supplied, the fields are assumed to beprivate In a struct, the fields are assumed to bepublic 29/09/2009 8 Hadziq Fabroyir - Informatics ITS
  • 9. What about protected? C++ allows users to create classes based on other classes: a FordCar class based on a general Car class idea: the general Car class has fields (variables and functions that describe all cars) the FordCar class then uses the fields from the general Car class and adds fields specific to FordCars done with inheritance public fields are inherited (as public) private fields are not inherited protected fields are like private, but can be inherited 29/09/2009 9 Hadziq Fabroyir - Informatics ITS
  • 10. Class Methods Functions associated with a class are declared in one of two ways: ReturnType FuncName(params) { code } function is both declared and defined (code provided) ReturnType FuncName(params); function is merely declared, we must still define the body of the function separately To call a method we use the . form: classinstance.FuncName(args); FuncName is a field just like any other field in the structured variable classinstance 29/09/2009 10 Hadziq Fabroyir - Informatics ITS
  • 11. Defined Methods class Robot { public: float getX() { return locX; } }; Robot r1; The function getX is defined as part of class Robot To call this method: cout << r1.getX() << endl; // prints r1’s locX 29/09/2009 11 Hadziq Fabroyir - Informatics ITS
  • 12. Defining Methods Separately For methods that are declared but not defined in the class we need to provide a separate definition To define the method, you define it as any other function, except that the name of the function is ClassName::FuncName :: is the scope resolution operator, it allows us to refer to parts of a class or structure 29/09/2009 12 Hadziq Fabroyir - Informatics ITS
  • 13. A Simple Class class Robot { public: void setLocation(float x, float y); private: float locX; float locY; float facing; }; void Robot::setLocation(float x, float y) { if ((x < 0.0) || (y < 0.0)) cout << “Illegal location!!” << endl; else { locX = x; locY = y; } } 29/09/2009 13 Hadziq Fabroyir - Informatics ITS
  • 14. Types of Class Methods Generally we group class methods into three broad categories: accessors - allow us to access the fields of a class instance (examples: getX, getY, getFacing), accessors do not change the fields of a class instance mutators - allow us to change the fields of a class instance (examples: setLocation, setFacing), mutators do change the fields of a class instance manager functions- specific functions (constructors, destructors) that deal with initializing and destroying class instances (more in a bit) 29/09/2009 14 Hadziq Fabroyir - Informatics ITS
  • 15. Accessors & Mutators Why do we bother with accessors and mutators? Why provide getX()?? Why not just make the locX field publicly available? By restricting access using accessors and mutators we make it possible to change the underlying details regarding a class without changing how people who use that class interact with the class Example: what if I changed the robot representation so that we no longer store locX and locY, instead we use polar coordinates (distance and angle to location)? If locX is a publicly available field that people have been accessing it, removing it will affect their code If users interact using only accessors and mutators then we can change things without affecting their code 29/09/2009 15 Hadziq Fabroyir - Informatics ITS
  • 16. Rewritten Robot Class class Robot { public: float getX() { return dist * cos(ang); } float getY() { return dist * sin(ang); } void setLocation(float x, float y); private: float dist; float ang; }; void Robot::setLocation(float x, float y) { if ((x < 0.0) || (y < 0.0)) cout << “Illegal location!!” << endl; else { dist = sqrt(x * x + y * y); ang = atan2(y,x); } } 29/09/2009 16 Hadziq Fabroyir - Informatics ITS
  • 17. Object-Oriented Idea Declare implementation-specific fields of class to be private Provide public accessor and mutator methods that allow other users to connect to the fields of the class often provide an accessor and mutator for each instance variable that lets you get the current value of that variable and set the current value of that variable to change implementation, make sure accessors and mutators still provide users what they expect 29/09/2009 17 Hadziq Fabroyir - Informatics ITS
  • 18. Static Instance Variables C++ classes may also contain, static instance fields -- a single field shared by all members of a class Often used when declaring class constants (since you generally only need one copy of a constant) To make a field static, add the static keyword in front of the field can refer to the field like any other field (but remember, everybody shares one copy) static variables are also considered to be global, you can refer to them without an instance static fields can be initialized (unlike other fields) 29/09/2009 18 Hadziq Fabroyir - Informatics ITS
  • 19. Static Fields Example class Robot { public: static int numRobots = 0; static const float minX = 0.0; static const float maxX = 100.0; void initializeRobot() { numRobots++; } void setLocation(float x, float y); } void Robot::setLocation(float x, float y) { if ((x < minX) || (x > maxX)) … } 29/09/2009 19 Hadziq Fabroyir - Informatics ITS
  • 20. Static Fields as Global Variables One can examine public static fields of a class outside of that class using the form: ClassName::StaticFieldName Example: void main() { Robot r1, r2; r1.initializeRobot(); r2.initializeRobot(); cout << Robot::numRobots << “ robots.”; 29/09/2009 20 Hadziq Fabroyir - Informatics ITS
  • 21. The Need for Manager Functions To make the previous program work we have to explicitly call the routine initializeRobot, wouldn’t it be nice to have a routine that is automatically used to initialize an instance -- C++ does C++ provides for the definition of manager functions to deal with certain situations: constructors (ctor) - used to set up new instances default - called for a basic instance copy - called when a copy of an instance is made (assignment) other - for other construction situations destructors (dtor) - used when an instance is removed 29/09/2009 21 Hadziq Fabroyir - Informatics ITS
  • 22. When Managers Called void main() { Robot r1; // default ctor (on r1) Robot r2; // default ctor (on r2) Robot* r3ptr; r3ptr = new Robot; // default ctor on // Robot object r3ptr points to r2 = r1; // copy ctor delete r3ptr; // dtor } // dtor (on r1 and r2) when main ends 29/09/2009 22 Hadziq Fabroyir - Informatics ITS
  • 23. The Default Constructor (ctor) A default constructor has no arguments, it is called when a new instance is created C++ provides a default ctor that initializes all fields to 0 To write your own, add following to your class: class MyClass { public: … MyClass() { // repeat class name, no code here // return type } } 29/09/2009 23 Hadziq Fabroyir - Informatics ITS
  • 24. Example Default ctor class Robot { public: static int numRobots = 0; Robot() { numRobots++; locX = 0.0; locY = 0.0; facing = 3.1415 / 2; } private: float locX; float locY; float facing; } 29/09/2009 24 Hadziq Fabroyir - Informatics ITS
  • 25. Destructor (dtor) A destructor is normally not critical, but if your class allocates space on the heap, it is useful to deallocate that space before the object is destroyed C++ provides a default dtor that does nothing can only have one dtor To write your own, add following to your class: class MyClass { public: … ~MyClass() { code here } } 29/09/2009 25 Hadziq Fabroyir - Informatics ITS
  • 26. Example dtor class Robot { public: char *robotName; Robot() { robotName = 0; } void setRobotName(char *name) { robotName = new char[strlen(name)+1]; strcpy(robotName,name); } ~Robot() { delete [] robotName; } } 29/09/2009 26 Hadziq Fabroyir - Informatics ITS
  • 27. The Copy ctor A copy constructor is used when we need a special method for making a copy of an instance example, if one instance has a pointer to heap-allocated space, important to allocate its own copy (otherwise, both point to the same thing) To write your own, add following to your class: class MyClass { public: … MyClass(const MyClass& obj) { code here } } 29/09/2009 27 Hadziq Fabroyir - Informatics ITS
  • 28. Example Copy ctor class Robot { public: char *robotName; void setRobotName(char *name) { robotName = new char[strlen(name)+1]; strcpy(robotName,name); } Robot(const Robot& obj) { robotName = new char[strlen(obj.robotName)+1]; strcpy(robotName,obj.robotName); } } 29/09/2009 28 Hadziq Fabroyir - Informatics ITS
  • 29. Other ctors It is often useful to provide constructors that allow the user to provide arguments in order to initialize arguments Form is similar to the copy ctor, except parameters are chosen by programmer: class MyClass { public; … MyClass(parameters) { code here } } 29/09/2009 29 Hadziq Fabroyir - Informatics ITS
  • 30. Example ctor class Robot { public: Robot(float x, float y, float face) { locX = x; locY = y; facing = face; } } calling: Robot r1(5.0,5.0,1.5); Robot r2(5.0,10.0,0.0); Robot* rptr; rptr = new Robot(10.0,5.0,-1.5); 29/09/2009 30 Hadziq Fabroyir - Informatics ITS
  • 31. A Combination ctor Can combine a ctor that requires arguments with the default ctor using default values: class Robot { public: Robot(float x = 0.0, float y = 0.0, float face = 1.57075) { locX = x; locY = y; facing = face; } } calling: Robot r1; // ctor called with default args Robot r2(); // ctor called with default args Robot r3(5.0); // ctor called with x = 5.0 Robot r4(5.0,5.0); // ctor called with x,y = 5.0 … 29/09/2009 31 Hadziq Fabroyir - Informatics ITS
  • 32. Hiding the Default ctor Sometimes we want to make sure that the user gives initial values for some fields, and we don’t want them to use the default ctor To accomplish this we declare an appropriate ctor to be used in creating instances of the class in the public area, then we put the default ctor in the private area (where it cannot be called) 29/09/2009 32 Hadziq Fabroyir - Informatics ITS
  • 33. Example ctor class Robot { public: Robot(float x, float y, float face) { locX = x; locY = y; facing = face; } private: Robot() {} } calling: Robot r1(5.0,5.0,1.5); Robot r2; // ERROR, attempts to call default ctor 29/09/2009 33 Hadziq Fabroyir - Informatics ITS
  • 34. For your practice … Exercise 9.5 Complex Class Properties: float realPart, float imaginaryPart Method (Mutators): Complex addBy(Complex), ComplexSubstractBy(Complex) Lab Session for upper order (Senin, 15.00-17.00) Lab Session for lower order (Senin, 19.00-21.00) Please provide: the softcopy(send it by email – deadline Sunday 23:59) the hardcopy(bring it when attending the lab session) 29/09/2009 Hadziq Fabroyir - Informatics ITS 34
  • 35. ☺~ Next: C++ OOP :: Overloading ~☺ [ 35 ] Hadziq Fabroyir - Informatics ITS 29/09/2009