Basics of Object Oriented Programming: Introduction, Features, and More

slide1 n.w
1 / 31
Embed
Share

Explore the fundamentals of Object Oriented Programming (OOP) including concepts like inheritance, polymorphism, operator overloading, and file handling. Get insights into the basics, features, and practical aspects of OOP through real-world examples and learn about creating objects, defining classes, constructors, and more.

  • OOP Basics
  • Programming Concepts
  • Inheritance
  • Polymorphism
  • Object Oriented

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. OOP By Muhammad Waris Zargar

  2. Introduction Basics Of Object Oriented Programming Operator Overloading Inheritance Polymorphism File Handling Exception Handling

  3. Basics Of Object Oriented Programming www.wariszargar.wordpress.com Introduction Of OOP Features Of OOP I. II. Object Classes Real World Modeling Reuse Ability Information Hiding Poly Morphism I. Objects Properties Of Object(MAN,CAR,TREE etc.) Definition

  4. Basics Of Object Oriented Programming www.wariszargar.wordpress.com I. II. Definatin Declaring A Class I. Acces Specifire Public Private Protected Function Of Objects Classes

  5. Basics Of Object Oriented Programming www.wariszargar.wordpress.com I. II. III. IV. V. VI. Creating Object At Least 2 Programme Defining Member Function Outside The Class Constructor Passing Parameter To The Constructor Constructor Overloading

  6. Basics Of Object Oriented Programming www.wariszargar.wordpress.com I. II. III. IV. V. VI. VII. VIII. IX. Copy Constructor Default Value To Constructor Destructor Object As A Function Parameter Returning Object From Member Function Static Data Member Static Member Function Friend Function Friend Class

  7. Thanks Visit My Website And Subscribe My Channel Channel Waris Zargar www.wariszargar.wordpress.com Contact :: +923086529243 Gmail :: waris.zargar123@gmail.com Face Book :: wariszargar65@gmail.com

  8. Introduction Of OOP Basis Of Object Object Collection Object Grouped To Gether

  9. Features Of OOP Object: It is collection of data member and member function. Data Member: Simply Variable in class are called data member. Member Function: Simply Function in class are called member function

  10. Features Of OOP Class: Classes are used to create different object. Class is a user define data type which allows to group together data member and member function. Class name{ Access Specifire;}; Real World Modeling: OOP is based on real world modeling, things have properties and working capacities. Similirly object have data and function.

  11. Features Of OOP Reuseability OOP provide the facility to build a new class from already existence class (Inheritance) Advantage: Time Save And Less Complications Information Hiding: OOP provides the facilities to hide impotant information from user.

  12. Object It is collection of data and function. Every object has two features Properties Functionality or Working Properties: Man: Name, age, color, height etc. Car: Color, Registration No, Model etc. Functionality: Man: Eat, Sleep, Walk etc. Car: Start, Reverse, Break etc.

  13. ACCESS SPECIFIRE The method which is used to specify the access level of programme is called access specifire Public: This access specifier allows the user to access this data every where in the programme. No provide restriction. Private: This access specifier restrict to the user and it is not allowed to access the data outside the class. Protected: This specifier is used to access data only in parent class and derive class

  14. Scope Resolution Operator Change Access Level of programe. TO define member function outside the class. Declare In the class Defining outside the class Return type class name :: function name(){ }

  15. Constructor Same name as class name No return type Automatic call by c++ It is used to initialized the data member Class Waris{ Waris(){ Cout<< I am constructor good by I am automatic call and no return type by ; } };

  16. Passing Parameter To Constructor Local variable or data member. Class waris{ Public: Int age; Waris(int iage){ Age = iage; Cout<<iage; } }; Int main(){ Waris W(20); }

  17. Constructor Overloading Number Of parameter different Place different

  18. Default value to constructor When we pass parameter then assign value to the parameter This is called default value to constructor class waris{ Waris(int iage=0; string = no name ){s } }; Int main(){ Waris w; } If I am pass value or not pass value, then also constructor run and generate no error.

  19. Default Copy Constructor A type of constructor i.e. used to initialized an object with an other object is of same class is called default copy constructor. Its name as Default Copy Constructor because it is available by default in all classes. The user does not need to write separate constructor. It accept single object as a parameter. The parameter for default copy constructor given in parenthesis or using assignment operator. Class object (2ndObject); Class object = 2ndobject;

  20. Thanks Visit My Website And Subscribe My Channel Channel Waris Zargar www.wariszargar.wordpress.com Contact :: +923086529243 Gmail :: waris.zargar123@gmail.com Face Book :: wariszargar65@gmail.com

  21. Destructor It is opposite to the constructor Same name as class name Tild (~) symbol is used before name It is automatic call when object goes out of scope To released the memory It is most used full for pointer ~ClassName(){ Cout<< This is destructor ; }

  22. New keyword It is used to allocate memory dynamically It is allocate memory according to the type of pointer It returns the address to the pointer Pointer than work and collect data It is used to create simple variable , object , array

  23. Method: 1st Class name *ptr = new class name (parameter); 2nd Int *ptr ; Ptr = new int

  24. Delete keyword It is opposite to the new keyword It is used to release memory of Object, Data Member and Array It is useful when we use pointer in class It is used to released memory

  25. Object As A Function Parmeter It is same as we pass parameter in function but when we pass object as a meter Then we use dot(.) operator to access the data. Class waris{ Public: Int age; string name; Void in(waris w){ Cout<< Enetr name and age ; Cin>>w.age>>w.name; Cout<< name :: <<w.name<<w.age; } }; Int main(){ waris h; h.in(h); }

  26. Return Object From Function It is same as return simple variable In function we make a temporary object and stored all value in object Void fun(class_name object){ Class_name temp_object; Cin>>temp_object.data_member; Return temp_object; }

  27. Static Data Member Use of static key-word to declare of static data member. This shared the location to all objects. One variable is created in memory If one change the value then all show the latest value. A = 10; A = 20 B = 90; B = 30 c = 30; C = 30;

  28. Globally initialized the static data member i.e. after the class Class waris{static int number; } ; Return_type class_name :: variable = fixed-point;

  29. Static Function Static function is used to display only the value of static data member Static void function(){ }

  30. Friend Function Normally the private and protected data member not access outside the calss. But use of friend function make possible to access data member outside the class But difference is that we define inside the class pass object of class as a parameter. After class define the function body. Class waris{ Friend return_type name(class_name oject); } Return_type name(class_name object){ Body; }

  31. Friend Class Normally the private and protected data member not access outside the calss. But use of friend class make possible to access data member in other class But difference is that we define inside the class. And make function and pass object. Class A{friend class B}; // this is called forward declaration Class B{ Void fun(A obj, B obj2); }

More Related Content