1. The document discusses the concepts of object-oriented programming including classes, objects, and member functions.
2. A class defines the data attributes and behaviors of a type of object. An object is an instance of a class that stores its own set of data attributes and can access class member functions.
3. The example defines a Book class with private data attributes (name, pages, price) and public member functions to change attribute values and display an object's attributes.
C++ was originally developed as an extension of C to add object-oriented capabilities. While C++ retains much of C's syntax and functionality, it introduces important new concepts like classes, objects, and inheritance. A class defines the common properties and behaviors (methods) that objects of that class will have. Objects are instances of classes that allocate memory at runtime. This allows C++ to support object-oriented programming by encapsulating data into objects that can receive messages.
C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX
Most C++ compilers don't care what extension you give your source code, but if you don't specify otherwise, many will use .cpp by default
Most frequently used and free available compiler is GNU C/C++ compiler, otherwise you can have compilers either from HP or Solaris if you have respective Operating Systems.
software development practices like procedural coding are like training wheels, they help when we start development, but are detrimental later. This presentation lists few such practices and their alternatives
This document provides an introduction and overview of data structures and algorithms. It begins by outlining the topics that will be covered, including data structures, algorithms, abstract data types, and object-oriented programming. It then defines what a data structure is and provides examples. Different types of data structures are discussed, including linear structures like lists, queues, and stacks, as well as non-linear structures like trees, graphs, and hash tables. The document also defines what an algorithm is and discusses why algorithms are important. It provides examples of successful algorithms and discusses the need for correctness and efficiency in algorithms. The relationship between programs, data structures, and algorithms is also briefly explained.
This lecture covers overloaded functions, constant objects and member functions, friend functions, the this pointer, static data members, and composition with objects as members of classes. Specifically, it discusses:
1) Overloading constructors to initialize objects with different values.
2) Using const to declare objects, member functions, and data members as constant to prevent modification.
3) Defining member functions outside the class and using the scope resolution operator.
4) Passing objects as arguments to other functions and returning objects.
5) Using the this pointer implicitly and explicitly to access members of the current object.
6) Declaring static data members that are shared across all objects of a class.
This document provides an introduction to object-oriented programming in C++. It explains that object orientation involves breaking programs into self-contained objects defined by classes. A class defines the variables and functions of an object, while an object is an instance of a class. The document uses examples like a Car class to demonstrate how to define classes with header and implementation files, and create objects from classes in a main program. It notes that object orientation can make programs easier to understand and reuse code through breaking problems into objects.
This document provides an overview of object-oriented programming (OOP) and Java. It defines key OOP concepts like classes, objects, methods, attributes, inheritance, encapsulation, and polymorphism. It also introduces Java, describing it as a general-purpose, object-oriented programming language that is simple, portable, reliable, secure, and multithreaded. The document notes some of Java's advantages over C++ as well as its potential disadvantage of being slower than compiled languages like C.
This document provides an overview of object-oriented analysis and design. It discusses key concepts in object-oriented programming including objects, classes, attributes, methods, encapsulation, inheritance, polymorphism, associations, and persistence. The document uses examples like an employee payroll program to illustrate how an object-oriented approach models real-world entities as objects that can be easily modified, replaced and reused when requirements change.
02._Object-Oriented_Programming_Concepts.pptYonas D. Ebren
This document discusses object-oriented programming concepts and provides an example of analyzing a software development process using object-oriented principles. It describes a typical 5-step software development process of analysis, design, implementation, testing, and maintenance. It then introduces object-oriented programming concepts like modeling a problem as a set of collaborating objects and components. As an example, it analyzes the classic game Tetris in terms of its objects like pieces and boards, their properties and capabilities.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
The document discusses object-oriented programming concepts like classes, objects, methods, encapsulation, abstraction, and inheritance. It provides examples of defining classes with attributes and methods, creating objects, and accessing object properties and methods. Constructors (__init__()) are discussed as special methods that initialize objects. Encapsulation, information hiding, and abstraction are presented as key concepts for modeling real-world objects in code with public and private interfaces.
This document discusses object-oriented concepts in software development. It describes the four main types of object-oriented paradigms used in the software lifecycle: object-oriented analysis, design, programming, and testing. It then explains some benefits of the object-oriented approach like modularity, reusability, and mapping to real-world entities. Key concepts like inheritance, encapsulation, and polymorphism are defined. The document also provides examples of how classes and objects are represented and compares procedural with object-oriented programming.
1. Object oriented programming (OOP) is a programming paradigm that models concepts as "objects" that contain data and functionality.
2. A class defines the format for objects, including attributes like properties and behaviors like methods. Creating an object from a class is like a real-world object.
3. OOP concepts like encapsulation, inheritance, and polymorphism address limitations of procedural programming by combining related data and functions into classes and objects. Encapsulation wraps data and functions together, hiding implementation details.
This document discusses Angular components, dependency injection, and routing. It defines Angular as being built on modules, components, templates, and services. Components are the basic building blocks and make up a hierarchical tree structure. Dependency injection allows components to access services. Routing in Angular uses a router to navigate between views and components based on URL changes.
AngularJS is a framework for building client-side web applications. It uses HTML as the template language and extends HTML attributes with directives. AngularJS applications are made up of modules that contain controllers, services, and directives to add dynamic behavior. Data binding in Angular updates the view automatically when the model changes. Key features include directives, two-way data binding, MVC pattern, dependency injection and routing.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
This document discusses JavaScript performance best practices. It covers loading and execution performance, DOM scripting performance, and patterns to minimize repaints and reflows. Some key points include batching DOM changes, event delegation to reduce event handlers, and taking elements out of the document flow during animations. References are provided to resources on JavaScript performance testing and design patterns.
The document provides an introduction to object oriented programming (OOP) by comparing it to procedural programming. It discusses that OOP treats data as a critical element and ties data more closely to functions that operate on it. It allows decomposition of problems into objects that contain both data and functions. The four main pillars of OOP are discussed as objects, classes, encapsulation, and inheritance. Classes are defined as collections of similar objects that define attributes and behaviors of objects. Constructors and different types of constructors like parameterized and copy constructors are also introduced.
ER diagram slides for datanase stujdy-1.pdfSadiaSharmin40
The document discusses database schema design using the entity-relationship (ER) model. It describes the database design process, which involves requirements analysis, conceptual design, and implementation including logical and physical design. The conceptual design phase develops a high-level description of the database using a technique like ER modeling. ER modeling represents entities, entity sets, attributes, relationships, and keys graphically. Relationships associate entities and define how they are related. The conceptual schema and functional requirements are then implemented through logical and physical database design.
The document provides an overview of system development methodologies, with a focus on structured analysis and design versus object-oriented analysis and design. It discusses the analysis, design, and implementation phases of an object-oriented systems development life cycle. In the analysis phase, it describes how use case diagrams and class diagrams are used to model object-oriented analysis using the Unified Modeling Language. It also provides guidance on identifying domain classes from problem statements by looking for noun phrases and applying subject matter expertise.
This document provides an introduction to object-oriented programming in C++. It explains that object orientation involves breaking programs into self-contained objects defined by classes. A class defines the variables and functions of an object, while an object is an instance of a class. The document uses examples like a Car class to demonstrate how to define classes with header and implementation files, and create objects from classes in a main program. It notes that object orientation can make programs easier to understand and reuse code through breaking problems into objects.
This document provides an overview of object-oriented programming (OOP) and Java. It defines key OOP concepts like classes, objects, methods, attributes, inheritance, encapsulation, and polymorphism. It also introduces Java, describing it as a general-purpose, object-oriented programming language that is simple, portable, reliable, secure, and multithreaded. The document notes some of Java's advantages over C++ as well as its potential disadvantage of being slower than compiled languages like C.
This document provides an overview of object-oriented analysis and design. It discusses key concepts in object-oriented programming including objects, classes, attributes, methods, encapsulation, inheritance, polymorphism, associations, and persistence. The document uses examples like an employee payroll program to illustrate how an object-oriented approach models real-world entities as objects that can be easily modified, replaced and reused when requirements change.
02._Object-Oriented_Programming_Concepts.pptYonas D. Ebren
This document discusses object-oriented programming concepts and provides an example of analyzing a software development process using object-oriented principles. It describes a typical 5-step software development process of analysis, design, implementation, testing, and maintenance. It then introduces object-oriented programming concepts like modeling a problem as a set of collaborating objects and components. As an example, it analyzes the classic game Tetris in terms of its objects like pieces and boards, their properties and capabilities.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
The document discusses object-oriented programming concepts like classes, objects, methods, encapsulation, abstraction, and inheritance. It provides examples of defining classes with attributes and methods, creating objects, and accessing object properties and methods. Constructors (__init__()) are discussed as special methods that initialize objects. Encapsulation, information hiding, and abstraction are presented as key concepts for modeling real-world objects in code with public and private interfaces.
This document discusses object-oriented concepts in software development. It describes the four main types of object-oriented paradigms used in the software lifecycle: object-oriented analysis, design, programming, and testing. It then explains some benefits of the object-oriented approach like modularity, reusability, and mapping to real-world entities. Key concepts like inheritance, encapsulation, and polymorphism are defined. The document also provides examples of how classes and objects are represented and compares procedural with object-oriented programming.
1. Object oriented programming (OOP) is a programming paradigm that models concepts as "objects" that contain data and functionality.
2. A class defines the format for objects, including attributes like properties and behaviors like methods. Creating an object from a class is like a real-world object.
3. OOP concepts like encapsulation, inheritance, and polymorphism address limitations of procedural programming by combining related data and functions into classes and objects. Encapsulation wraps data and functions together, hiding implementation details.
This document discusses Angular components, dependency injection, and routing. It defines Angular as being built on modules, components, templates, and services. Components are the basic building blocks and make up a hierarchical tree structure. Dependency injection allows components to access services. Routing in Angular uses a router to navigate between views and components based on URL changes.
AngularJS is a framework for building client-side web applications. It uses HTML as the template language and extends HTML attributes with directives. AngularJS applications are made up of modules that contain controllers, services, and directives to add dynamic behavior. Data binding in Angular updates the view automatically when the model changes. Key features include directives, two-way data binding, MVC pattern, dependency injection and routing.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
This document discusses JavaScript performance best practices. It covers loading and execution performance, DOM scripting performance, and patterns to minimize repaints and reflows. Some key points include batching DOM changes, event delegation to reduce event handlers, and taking elements out of the document flow during animations. References are provided to resources on JavaScript performance testing and design patterns.
The document provides an introduction to object oriented programming (OOP) by comparing it to procedural programming. It discusses that OOP treats data as a critical element and ties data more closely to functions that operate on it. It allows decomposition of problems into objects that contain both data and functions. The four main pillars of OOP are discussed as objects, classes, encapsulation, and inheritance. Classes are defined as collections of similar objects that define attributes and behaviors of objects. Constructors and different types of constructors like parameterized and copy constructors are also introduced.
ER diagram slides for datanase stujdy-1.pdfSadiaSharmin40
The document discusses database schema design using the entity-relationship (ER) model. It describes the database design process, which involves requirements analysis, conceptual design, and implementation including logical and physical design. The conceptual design phase develops a high-level description of the database using a technique like ER modeling. ER modeling represents entities, entity sets, attributes, relationships, and keys graphically. Relationships associate entities and define how they are related. The conceptual schema and functional requirements are then implemented through logical and physical database design.
The document provides an overview of system development methodologies, with a focus on structured analysis and design versus object-oriented analysis and design. It discusses the analysis, design, and implementation phases of an object-oriented systems development life cycle. In the analysis phase, it describes how use case diagrams and class diagrams are used to model object-oriented analysis using the Unified Modeling Language. It also provides guidance on identifying domain classes from problem statements by looking for noun phrases and applying subject matter expertise.
What makes space feel generous, and how architecture address this generosity in terms of atmosphere, metrics, and the implications of its scale? This edition of #Untagged explores these and other questions in its presentation of the 2024 edition of the Master in Collective Housing. The Master of Architecture in Collective Housing, MCH, is a postgraduate full-time international professional program of advanced architecture design in collective housing presented by Universidad Politécnica of Madrid (UPM) and Swiss Federal Institute of Technology (ETH).
Yearbook MCH 2024. Master in Advanced Studies in Collective Housing UPM - ETH
How to Manage Opening & Closing Controls in Odoo 17 POSCeline George
In Odoo 17 Point of Sale, the opening and closing controls are key for cash management. At the start of a shift, cashiers log in and enter the starting cash amount, marking the beginning of financial tracking. Throughout the shift, every transaction is recorded, creating an audit trail.
pulse ppt.pptx Types of pulse , characteristics of pulse , Alteration of pulsesushreesangita003
what is pulse ?
Purpose
physiology and Regulation of pulse
Characteristics of pulse
factors affecting pulse
Sites of pulse
Alteration of pulse
for BSC Nursing 1st semester
for Gnm Nursing 1st year
Students .
vitalsign
Link your Lead Opportunities into Spreadsheet using odoo CRMCeline George
In Odoo 17 CRM, linking leads and opportunities to a spreadsheet can be done by exporting data or using Odoo’s built-in spreadsheet integration. To export, navigate to the CRM app, filter and select the relevant records, and then export the data in formats like CSV or XLSX, which can be opened in external spreadsheet tools such as Excel or Google Sheets.
Contact Lens:::: An Overview.pptx.: OptometryMushahidRaza8
A comprehensive guide for Optometry students: understanding in easy launguage of contact lens.
Don't forget to like,share and comments if you found it useful!.
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...larencebapu132
This is short and accurate description of World war-1 (1914-18)
It can give you the perfect factual conceptual clarity on the great war
Regards Simanchala Sarab
Student of BABed(ITEP, Secondary stage)in History at Guru Nanak Dev University Amritsar Punjab 🙏🙏
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetSritoma Majumder
Introduction
All the materials around us are made up of elements. These elements can be broadly divided into two major groups:
Metals
Non-Metals
Each group has its own unique physical and chemical properties. Let's understand them one by one.
Physical Properties
1. Appearance
Metals: Shiny (lustrous). Example: gold, silver, copper.
Non-metals: Dull appearance (except iodine, which is shiny).
2. Hardness
Metals: Generally hard. Example: iron.
Non-metals: Usually soft (except diamond, a form of carbon, which is very hard).
3. State
Metals: Mostly solids at room temperature (except mercury, which is a liquid).
Non-metals: Can be solids, liquids, or gases. Example: oxygen (gas), bromine (liquid), sulphur (solid).
4. Malleability
Metals: Can be hammered into thin sheets (malleable).
Non-metals: Not malleable. They break when hammered (brittle).
5. Ductility
Metals: Can be drawn into wires (ductile).
Non-metals: Not ductile.
6. Conductivity
Metals: Good conductors of heat and electricity.
Non-metals: Poor conductors (except graphite, which is a good conductor).
7. Sonorous Nature
Metals: Produce a ringing sound when struck.
Non-metals: Do not produce sound.
Chemical Properties
1. Reaction with Oxygen
Metals react with oxygen to form metal oxides.
These metal oxides are usually basic.
Non-metals react with oxygen to form non-metallic oxides.
These oxides are usually acidic.
2. Reaction with Water
Metals:
Some react vigorously (e.g., sodium).
Some react slowly (e.g., iron).
Some do not react at all (e.g., gold, silver).
Non-metals: Generally do not react with water.
3. Reaction with Acids
Metals react with acids to produce salt and hydrogen gas.
Non-metals: Do not react with acids.
4. Reaction with Bases
Some non-metals react with bases to form salts, but this is rare.
Metals generally do not react with bases directly (except amphoteric metals like aluminum and zinc).
Displacement Reaction
More reactive metals can displace less reactive metals from their salt solutions.
Uses of Metals
Iron: Making machines, tools, and buildings.
Aluminum: Used in aircraft, utensils.
Copper: Electrical wires.
Gold and Silver: Jewelry.
Zinc: Coating iron to prevent rusting (galvanization).
Uses of Non-Metals
Oxygen: Breathing.
Nitrogen: Fertilizers.
Chlorine: Water purification.
Carbon: Fuel (coal), steel-making (coke).
Iodine: Medicines.
Alloys
An alloy is a mixture of metals or a metal with a non-metal.
Alloys have improved properties like strength, resistance to rusting.
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingCeline George
The Accounting module in Odoo 17 is a complete tool designed to manage all financial aspects of a business. Odoo offers a comprehensive set of tools for generating financial and tax reports, which are crucial for managing a company's finances and ensuring compliance with tax regulations.
This chapter provides an in-depth overview of the viscosity of macromolecules, an essential concept in biophysics and medical sciences, especially in understanding fluid behavior like blood flow in the human body.
Key concepts covered include:
✅ Definition and Types of Viscosity: Dynamic vs. Kinematic viscosity, cohesion, and adhesion.
⚙️ Methods of Measuring Viscosity:
Rotary Viscometer
Vibrational Viscometer
Falling Object Method
Capillary Viscometer
🌡️ Factors Affecting Viscosity: Temperature, composition, flow rate.
🩺 Clinical Relevance: Impact of blood viscosity in cardiovascular health.
🌊 Fluid Dynamics: Laminar vs. turbulent flow, Reynolds number.
🔬 Extension Techniques:
Chromatography (adsorption, partition, TLC, etc.)
Electrophoresis (protein/DNA separation)
Sedimentation and Centrifugation methods.
The Pala kings were people-protectors. In fact, Gopal was elected to the throne only to end Matsya Nyaya. Bhagalpur Abhiledh states that Dharmapala imposed only fair taxes on the people. Rampala abolished the unjust taxes imposed by Bhima. The Pala rulers were lovers of learning. Vikramshila University was established by Dharmapala. He opened 50 other learning centers. A famous Buddhist scholar named Haribhadra was to be present in his court. Devpala appointed another Buddhist scholar named Veerdeva as the vice president of Nalanda Vihar. Among other scholars of this period, Sandhyakar Nandi, Chakrapani Dutta and Vajradatta are especially famous. Sandhyakar Nandi wrote the famous poem of this period 'Ramcharit'.
A measles outbreak originating in West Texas has been linked to confirmed cases in New Mexico, with additional cases reported in Oklahoma and Kansas. The current case count is 817 from Texas, New Mexico, Oklahoma, and Kansas. 97 individuals have required hospitalization, and 3 deaths, 2 children in Texas and one adult in New Mexico. These fatalities mark the first measles-related deaths in the United States since 2015 and the first pediatric measles death since 2003.
The YSPH Virtual Medical Operations Center Briefs (VMOC) were created as a service-learning project by faculty and graduate students at the Yale School of Public Health in response to the 2010 Haiti Earthquake. Each year, the VMOC Briefs are produced by students enrolled in Environmental Health Science Course 581 - Public Health Emergencies: Disaster Planning and Response. These briefs compile diverse information sources – including status reports, maps, news articles, and web content– into a single, easily digestible document that can be widely shared and used interactively. Key features of this report include:
- Comprehensive Overview: Provides situation updates, maps, relevant news, and web resources.
- Accessibility: Designed for easy reading, wide distribution, and interactive use.
- Collaboration: The “unlocked" format enables other responders to share, copy, and adapt seamlessly. The students learn by doing, quickly discovering how and where to find critical information and presenting it in an easily understood manner.
CURRENT CASE COUNT: 817 (As of 05/3/2025)
• Texas: 688 (+20)(62% of these cases are in Gaines County).
• New Mexico: 67 (+1 )(92.4% of the cases are from Eddy County)
• Oklahoma: 16 (+1)
• Kansas: 46 (32% of the cases are from Gray County)
HOSPITALIZATIONS: 97 (+2)
• Texas: 89 (+2) - This is 13.02% of all TX cases.
• New Mexico: 7 - This is 10.6% of all NM cases.
• Kansas: 1 - This is 2.7% of all KS cases.
DEATHS: 3
• Texas: 2 – This is 0.31% of all cases
• New Mexico: 1 – This is 1.54% of all cases
US NATIONAL CASE COUNT: 967 (Confirmed and suspected):
INTERNATIONAL SPREAD (As of 4/2/2025)
• Mexico – 865 (+58)
‒Chihuahua, Mexico: 844 (+58) cases, 3 hospitalizations, 1 fatality
• Canada: 1531 (+270) (This reflects Ontario's Outbreak, which began 11/24)
‒Ontario, Canada – 1243 (+223) cases, 84 hospitalizations.
• Europe: 6,814
2. 2
Aim of the course
• This course provides
– motivation of object oriented programming
language
– in depth knowledge of the various concepts of
object oriented programming and its
implementation in C++
3. 3
Course book
• Text book
– C++ How to program by Deitel and Deitel
• Reference books
– Waite Group’s Object oriented programming in
C++, Robert Lafore
4. 4
Course outline
Classes, Objects, Member functions, Objects as data types, Constructors and
destructors, Overloaded constructor
The default copy constructor, Returning objects from functions, objects and
memory, Static class data, Constant member functions, Constant objects
Base classes and derived classes, Derived class constructors, Overloading
member functions, Scope resolution, Abstract classes, Public and private
inheritance, Levels of inheritance, Multiple inheritance, Aggregation and
composition
New and delete operators, Pointers to objects, Virtual functions and late
binding, Abstract classes and pure virtual functions, Virtual destructors, Virtual
base classes, Friend functions and friend classes, Static functions, this pointer,
Dynamic type information
Motivation for exception handling, Try-catch block, Throwing an exception,
Catching multiple exceptions
Streams and files, Templates
7. 7
Simple analogy
• You are driving a car
• You can pressing accelerator pedal
• Someone has design it and built it
• Engineering drawings car
• Drawings also includes design for accelerator
pedal to make car go faster
• We can say, pedal “hides” complex
mechanism that make the car go faster
8. 8
Cont.
• Brake pedal “hides” the mechanism that slow
the car
• Steering wheel “hides” the mechanism that
turn the car and so on
• Simple “interfaces” like accelerator and brake
pedal, steering wheel, transmission shift and
etc. allow driver to interact car’s complex
internal mechanisms
9. 9
Points to be noted
• You cannot drive the engineering design of a
car
• Before you can drive a car, it must be built
according to engineering design
• The car will not accelerator on its own, a
driver must press the accelerator pedal
10. 10
Object oriented programming concepts
• Function hides from user the complex task it
performs
• Same as accelerator pedal hides complex
mechanism of making the car go faster
• C++ makes a program unit called class that
houses various functions
• Same as car engineering design houses the
mechanism of accelerator pedal
11. 11
Cont.
• In C++, a class can have various functions that
are design to perform a class tasks
• For example, a class representing bank
account might contain functions
– Deposit money
– Withdraw money
– Current balance
12. 12
Car example
Real world
• Engineering drawing
cannot be drive
• A car is build from that
drawing
• Pressing accelerator
pedal sends a message
to car to perform task
(go faster)
C++ programming
• An object of a class must
be create to get a
program to perform the
tasks the class describes
• Message can be sent to
object by calling a
member functions
13. 13
Cont.
• Car analogy is used to introduce
– Class
– Objects
– Member functions
• In addition to capabilities of car, it has many
attributes
• Color, No. of doors, amount of gas in tank, total
miles driven and etc
• Attributes are part of car engineering drawing
14. 14
Cont.
• These attribute are always associated with the
car
• Every car maintains its own attribute
• Example 1: each car knows how much gas in its
own tank but do not know how much is in the
tanks of other cars
• Example 2: a bank account object has a balance
attribute. Each bank account object knows the
balance in its account not the others
15. 15
Object
• Look around right now and you'll find many
examples of real-world objects:
• your dog, your desk, your television set, your
bicycle.
• Real-world objects share two characteristics:
They all have
– State and
– Behavior
16. 16
Object example
• A dog x has state (name, color, breed, hungry)
and behavior (barking, fetching, wagging tail).
• Your bicycle also have state (current gear,
current pedal cadence, current speed) and
behavior (changing gear, changing pedal
cadence, applying brakes).
17. 17
Cont.
• For each object that you see, ask yourself two
questions:
– "What possible states can this object be in?" and
– "What possible behavior can this object perform?"
18. 18
Real world objects
• Real-world objects vary in complexity
– your desktop lamp may have only two possible
states (on and off) and two possible behaviors
(turn on, turn off),
– but your desktop radio might have additional
states (on, off, current volume, current station)
and behavior (turn on, turn off, increase volume,
decrease volume, seek, scan, and tune).
19. 19
Cont..
• You may also notice that some objects, in
turn, will also contain other objects.
• These real-world observations all translate
into the world of object-oriented
programming
20. 20
Class
• In the real world, you'll often find many individual
objects all of the same kind
• There may be thousands of other bicycles in
existence, all of the same make and model.
• Each bicycle was built from the same engineering
design and contains the same components.
• In object-oriented terms, we say that your bicycle
is an instance of the class of objects known as
bicycles.
21. 21
Software Object
• Software objects are conceptually similar to
real-world objects: they too consist of state
and related behavior. An object stores its
state in
– fields (variables in some programming languages)
and exposes its behavior through
– methods (functions in some programming
languages). A Software Object
22. 22
Cont.
• Methods operate on an object's internal state
and serve as the primary mechanism for
object-to-object communication.
23. 23
Class vs. Object
• Class is a blue print of an object, which is non-
live entity.
• Object is instance of class, which is a live
entity.
• Example:
– Employee is a class
– Fruit is a class
– I am an object
– apple is an object
24. 24
Points to remember
• A class is not a living entity, it is just a
engineering design that how an object of this
class look like
• Object are living entities
26. 26
Cont.
• Class definition
• Access specifier – Public
• Class’s body is enclosed in a pair of { }
• Class definition ends at semi colon
• Member function
• Class object
• Dot operator
29. 29
Class data
• The class book contain three data items
– char name[15];
– int pages;
– float price;
• There can be any number of data members in
a class just as in structure
• There data member lie under keyword private,
so they can be accessed from within the class,
but not outside
30. 30
Member function
• These functions are included in a class
• There are four member functions in class book
– changeName(char *n)
– changePages(int p)
– changePrice(float p)
– display()
• There functions are followed by a keyword
public, so they can be accessed outside the
class
31. 31
Class data and member function
• Access specifier label public and private
• Function are public and data is private
• Data is hidden so that it can be safe from
accidental manipulation
• Functions operates on data are public so they
can be accessed from outside the class
32. 32
Defining Objects
void main()
{
book b1;
b1.changeName("Operating System");
b1.changePages(500);
b1.changePrice(150.56);
b1.display();
}
Name
Pages
Price
b1
Operating system
500
150.56
33. 33
Cont.
• Defining an object is similar to defining a
variable of any data type: Space is set aside for
it in memory e.g. int x;
• Defining objects in this way (book b1;) means
creating them, also called instantiating them
• An object is an instance (that is, a specific
example) of a class. Objects are sometimes
called instance variables.
34. 34
Calling Member Functions
• The next four statements in main() call the
member function
– b1.changeName("Operating System");
– b1.changePages(500);
– b1.changePrice(150.56);
– b1.display();
• don’t look like normal function calls
• This syntax is used to call a member function that
is associated with a specific object
• It doesn’t make sense to say
– changeName("Operating System");
because a member function is always called to act on
a specific object, not on the class in general
35. 35
Cont.
• To use a member function, the dot operator
(the period) connects the object name and
the member function.
• The syntax is similar to the way we refer to
structure members, but the parentheses
signal that we’re executing a member function
rather than referring to a data item.
• The dot operator is also called the class
member access operator.
37. 37
Example program – Distance class
• Data members
– Feet
– Inches
• Member functions
– void setdist(int ft, float in);
– void getdist();
– void initialize();
– void showdist();
Go to program
38. 38
Constructors
• The Distance example shows two ways that member
functions can be used to give values to the data items
in an object
• It is convenient if an object can initialize itself when it’s
first created, without requiring a separate call to a
member function
• Automatic initialization is carried out using a special
member function called a constructor.
• A constructor is a member function that is executed
automatically whenever an object is created.
39. 39
A counter example
• Data member
– Count
• Member function
– Constructor
– void inc_count()
– int get_count()
Go to program