c programming for engineers object oriented programming
play

C Programming for Engineers Object Oriented Programming ICEN 360 - PowerPoint PPT Presentation

C Programming for Engineers Object Oriented Programming ICEN 360 Spring 2017 Prof. Dola Saha 1 Evolution of computers Early computers were far less complex than todays computers Modern computers are smaller, but more complex 2


  1. C Programming for Engineers Object Oriented Programming ICEN 360– Spring 2017 Prof. Dola Saha 1

  2. Evolution of computers Ø Early computers were far less complex than today’s computers Ø Modern computers are smaller, but more complex 2

  3. Objects Ø Computer scientists have introduced the notion of objects and object-oriented programming to help manage the growing complexity of modern computers. Ø Object is anything that can be represented by data in computer’s memory 3

  4. Properties Ø The data that represent the object are organized into a set of properties . Name : PA 3794 Owner : US Airlines Ø The values stored in an Location : 39 52′ 06″ N 75 13′ 52″ W object’s properties at any Heading : 271° one time form the state of Altitude : 19 m an object. AirSpeed : 0 Make : Boeing Model : 737 Weight : 32,820 kg 4

  5. Methods Ø In object-oriented programming, the programs that manipulate the properties of an object are the object’s methods . Ø We can think of an object as a collection of properties and the methods that are used to manipulate those properties. 5

  6. Class Ø A class is a group of objects with the same properties and the same methods. Class <CAR> Object Object Object <7_series_BMW> <Ford_Mustang> <VW_Beetle> 6

  7. Instance Ø Each copy of an object from a particular class is called an instance of the object. Ø The act of creating a new instance of an object is called instantiation. Ø Two different instances of the same class will have the same properties, but different values stored in those properties. 7

  8. Terminology Object Property The same terminology is used Instantiation in most object-oriented Method programming languages. Class Instance State 8

  9. First OOP in C++ 9

  10. Access Specifier: Public & Private Ø Keyword public or private is an access specifier. Ø Access specifiers are always followed by a colon (:) Ø Public: Ø Accessible to public—that is, it can be called by other functions in the program (such as main), and by member functions / methods of other classes (if there are any). Ø Private: Ø Accessible only to member functions / methods of the class for which they are declared. 10

  11. Passing value 11

  12. Classroom Assignment Ø Extend the second OOP to § Call the method twice with two different messages § Instantiate two gradebooks and display different messages 12

  13. Example object with properties & methods (1) 13

  14. Example object with properties & methods (2) 14

  15. Example object with properties & methods (3) 15

  16. Constructor and Destructor Ø A constructor is a special function that gets called automatically when the object of a class is created. Ø A destructor is a special function that gets called automatically when an object is deleted. 16

  17. Constructor Example 17

  18. Constructor Example 18

  19. Constructor Example 19

  20. Separate Function definition & declaration 20

  21. Separate Function definition & declaration 21

  22. Separate Function definition & declaration 22

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend