Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
7 views
c++ programming
notes
Uploaded by
anandyadav88793244
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save c++ programming For Later
Download
Save
Save c++ programming For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
7 views
c++ programming
notes
Uploaded by
anandyadav88793244
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save c++ programming For Later
Carousel Previous
Carousel Next
Save
Save c++ programming For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 8
Search
Fullscreen
11 INTRODUCTION Object-Oriented Parady cus real Ife objects Wis | programing any solution. By focusing real life objects, we Mean that Ove, solutions revolves around different objects, which represent Tespectiyg | objects in real life situation, : Object-oriented Progra: where all computations imming, or OOP, is an approach to Problem-solvig 5 are carried out using objects, Traditional programming techniques using data real-world Concepts, Object-oriented Programmi language model organized around objects rath than logic, Hence, emphasis is given Procedures, In OOP, code and dats ar¢ merged into a single indivisible thing - an object. So, programs are divided into what are as objects, Data Structures are designed such that they characterize the objects. and functions do not moda | ing (OOP) isa Programming | ler than “actions” and datz | More on data rather than Functions that operate on the data of an object are tied together in the datz structure, } Chg Object B Data Functions muse 7 Functions Data Yigure 11 : Organteation of Data and Functions in OOP1.2 ‘ADVANTAGES AND DISADVANTAGES OF PROCEDURE ORIENTED LANGUAGES excrete etodeeay ore Data is hidden using Encapsulation property and cannot be accessed by external functions. This characteristic of data hiding provides greater system security and avoids unintended data corruption. Functions are used for objects to communicate with each other. Object Oriented Language tries to make parts of programs easily reusable and extensible. Hence, new data and functions can be easily added whenever necessary. It follows bottom- up approach in program design. The organization of data and functions in object-oriented programs is as shown in Figure 1.1. The data of an object can be accessed only by the functions associated with that object. However, functions of one object can access the functions of other objects. procedure-Oriented Languages (POLs) focus on writing functions (or procedures) to perform tasks, like a recipe with steps. Examples are C and Pascal. [ADVANTAGES OF PROCEDURE-ORIENTED LANGUAGES : 1 Easy to Break Down : You can divide a big task into smaller steps (functions), making the program easier to handle. Re-use Code: Once you write 4 function, you can use it again and again without rewriting it. Clear Process Flow : It follows a logical order, like a step-by-step instruction manual. Siniple to Learn: Good for smalll projects; easy to understand when starting out. Fast and Efficient : Since you control how the computer uses memory; the programs can run fast. DisabvANTAGES OF PROCEDURE-ORIENTED LANGUAGES : Hard to Manage Large Programs : For big projects, keeping track of everything gets messy and hard to maintain. No Protection for Data : Any part of the program can change important data, No Inheritance : Unlike object-oriented languages, you can} which may lead to errors. not create new features by building on existing code, so you may repeat yourself more.a ented Programming using C++ (Ry, ; oo Object Orient 886 an, a 4. Less Focus on Data: ce Itis more about the steps (functions) than organizing or protecting the data, 5, Not Ideal for Real-World Modeling : It is harder to model real-world things like cars or users because the langua, focuses more on tasks than objects. Be 1,3 APPLICATION OF OOPS Here are some simple applications of Object-Oriented Programming (op), 1, Building User-Friendly Apps : i) Examples : Mobile apps, games, web browsers. ii) OOP helps create buttons, windows, and menus as objects, making it eas, 2 design apps with a user-friendly interface. 'Y to 2. Real-World Systems : : i) Examples: Train ticket booking, traffic systems. ii) OOP models real-world items like trains, tickets, and passengers as objects, making it easier to manage large, complex systems. 3. Simulations: i) _ Examples : Weather forecasting, business simulations. ii) OOP helps simulate real-world objects like clouds or financial markets, making it easier to predict outcomes. 4.. Cloud and Networked Applications : i) Examples : Cloud storage (Google Drive), online games. \i) OOP allows objects to exist on different computers, making it easier to build apps that work over the internet. 5. Managing Large Databases : 1) Examples : Online shopping sites, banking systems. fl) OOP uses objects to represent data like customer info or product details, making it easier to store and manage huge amounts of data. 6. Design Software : ') Examples: Architecture design, 3D modeling tools. if) OOP helps create complex designs, like buildings or machine parts, by modeling each part as an object. 7. Artificial Intelligence (Al) : {) Examples : Voice assistants (Siri), fl) OOP helps Al systems work by like users, images, or command: image recognition. using objects to represent different things, is.Ez yc orentd Methodology wee s q, Business Applications : i) Examples: Inventory systems, customer management. ii) OOP makes it easy to organize things like customers, products, or orders into objects, helping businesses run smoothly. 9, Game Development: i) Examples : Video games (e.g., FIFA, Call of Duty). ii) OOP lets developers create characters, weapons, and levels as objects, making games more interactive and realistic. 10. Security Systems : i) Examples : Password management, fingerprint scanners. i) OOP helps secure data by using objects to manage users and access rights. 11. Websites: i) Examples : Online stores, social media sites. ii) OOP helps build websites by representing users, posts, and products as objects, making web development more organized. In short, OOP makes it easier to model real-world things (like cars or users) as objects in code, which simplifies programming for complex applications. [1-4 PrincipLes OF OOPS 14.1 Opjects = Anobject represents an entity in the real world. «Definition : An object incorporates the combination of the set of data values as data members, and the set of operations as member function. = Each object has its own properties or characteristics that describe what it is or does. = For example, the properties of a Person object would be : Name, Age, Weight. = Some properties ofa Car object would be : Color, Weight, Model-year, Engine power, number of wheels. * An object also executes some actions. The actions a Car is capable of are: Start, Stop, Accelerate, Reverse. "The match between programming objects and real-world objects is the result of combining the properties and actions of an object. "= Whena program is executed, the objects interact by sending messages to one another. x ‘i Oriented Programming using C+: FYB.Sc. (IT) (Semester-I1)1.4.2 CLASSES . Each object is said to be an instance of its class. - Object Oriented Programming using C++ (FY.RSe, apy! wor OF Smtr ‘There are two ways of representing an object : h Object : CAR CAR | object:CAR . DATA Color Weight Model-Year ae Engine Poer ‘Number of Wheels a Accelerate FUNCTIONS I Start Stop Accelerate Reverse Start Reverse Figure 1.2 : Two Ways of Representing An Object Definition : A class is a group of objects that have the same Properties, common behavior, and common relationships. ‘The Class defines the characteristics that the object is to possess. However, values can be assigned only after an object is created. Class is a user defined data type, which holds its own data members and member functions, which can be accessed and used by creating instance of that class. For example, in a class of Polygons, a triangle, a square, a parallelogram, a rectangle and so on, is objects. a Class: Polygon. a Properties : Vertices, Border Color, Fill Color. © Methods : Draw, Erase, Move. The variables inside class definition are called as data members and the functions are called member functions. Property / Attribute / Data Member : The characteristic of the object is represented as the variables in a class and referred to as the properties or attributes of the class. For example, each polygon in a class has a name, vertices and edges, border color and fill color. All polygons in the class share these common properties. Method / Member Functions : All objects in a class perform certain common actions or operations. An action required of an object or entity represented in a class, is called a method. In a polygon class “draw”, “erase” and “move” are examples of the methods that are part of the class.r 144 L485, ented Method!” " rr ori 4, DATA EN \CAPSULATION at, pefinition : Encapsulation is the ; Properties and methods in a class, process that allows selective hiding of ‘The wrapping up of data and functi | known as Encapsulation. ctions into a single unit (called class) is The data is not accessible to the outsid tions which are wrapped in the class can ae wera and only those function All communication to an object is done vi interface to the object. e via messages. Messages define the So, these functions provide the interface between the object's data and the program. Providing access to an object only through its messages, while keeping the details private is called information hiding. When we properly encapsulate some code, we achieve two objectives : o We build an impenetrable wall to, protect the code from accidental corruption due to the minor errors that weare all prone to make. 1 We also isolate errors to small sections of code thereby making them easier to find and fix. DATA ABSTRACTION Definition : Data Abstraction is the process of identifying properties and methods related to a particular entity as relevant to the application. Common definitions are stored once per class rather than once per instance of the class. Methods can be written once for a class, so that all the objects in a class benefit from code reuse. For example, all ellipses share the same methods to: - draw them, compute their area, test for intersection with a line. In Object oriented programming data abstraction is defined asa collection of data and methods, which is what an object represents. INHERITANCE we use the concept of classes being divided into subclasses. Inour daily lives, trucks, buses, We know that a class of vehicles can be divided into-cars, motorcycles etc. Definition : Inheritance is the process by which the objects of one class acquire the properties of objects of another class. Inheritance is the property that allows the reuse of an existing class to build anew class. The principle in this sort properties with the class fr For example, all vehicles in a class wheels and a motor. of division is that each subclass shares common om which it is derived. may share similar properties of havingveer Object Ortented Programming using C+* (2 ¥.0 on Sen, the subclass may have Its own particular characteristi 4 es, Inadaition, tes example, a bus may have seats for people, while trucks hay carrying pods. Paty, rene as ners al the behavor of he original lass an yy aly * have its additional features. The original class is called the base class or super class, or parent the new class. a The new class is called the derived class, or subclass, or child clas ar OF original class. superclass is the class from which another class inherits its behavior The class that inherits the properties and methods of another class is Caley the subclass. In OOP, the concept of inheritance provides the idea of reusability, Note : Each subclass defines only those features that are unique to it, Vehicles _ Super Class / Parents Class / Base Class cars| [_Truts_] Buses Motorcycles Sub Class / Child Class / Derived Class Figure 1.3 A subclass is said to be a specialization of its superclass, and conversely, a super class is a generalization of its subclasses. 1.4.6 POLYMORPHISM Definition : Polymorphism means the ability to take more than one form at different times. In simple terms, polymorphism is the attribute that allows one interface to be used with a general class of actions. Shape Draw () Circle Object__| Box Object Triangle Object Draw (Circle) | Draw (Box) Draw (Triangle) Figure 1.4 = The above figure illustrates thata single function name can be used to handle different number and different types of arguments.yr ST | ethodol tet Methodoloay weer ore . 9 pet = @ method or function, which all the subclasses of the class Shape However, the Draw method that box and that for a triangle will be differe! fe implemented for a circle or for a bo: Hence, polymorphism promotes Encapsulation. Itis extensively used in implementing inheritance. 147, DYNAMICBINDING 1.48 MESSAGE PASSING Binding refers to the linking of a procedure call to the code to be executed in response to the call, Dynamic Binding (also known as late binding) means that the ciated with a given procedure call is not known until the time of the call run time. Itis associated with polymorphism and inheritance. code asso- I at A function call associated with a polymorphic reference depends on the dynamic type of that reference. f information by the Message Passing is nothing but sending and receiving 0 is helps in building objects same as people exchange information. So, thi: systems that simulate real life. ‘An object-oriented program consists of a set of objects that communicate with each other. The process of programming in an object-oriented language therefore involves the following basic steps : a _. Creating classes that define objects and their behavior. 0 Creating objects from class definitions. a Establishing communication among objects. ‘A message for an object is a request for execution of procedure, and therefore will invoke a function that generates the desired result. In OOPs, Message Passing involves specifying the name of objects, the name of the function, and the information to be sent. rrr
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
4/5 (6126)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
4/5 (627)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brene Brown
4/5 (1148)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
4.5/5 (932)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
4/5 (8215)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
4/5 (631)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
4/5 (1253)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
4/5 (8365)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
4.5/5 (860)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
4/5 (877)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
4.5/5 (361)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
4/5 (954)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
4/5 (2923)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
4.5/5 (484)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
4.5/5 (277)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
4.5/5 (4972)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
4.5/5 (444)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
3.5/5 (2061)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
4/5 (4281)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
4/5 (100)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
3.5/5 (447)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
3.5/5 (2283)
Yes Please
From Everand
Yes Please
Amy Poehler
4/5 (1987)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
4.5/5 (278)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
4/5 (1068)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
4/5 (1993)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
3.5/5 (2641)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
4.5/5 (1936)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
4.5/5 (125)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
3.5/5 (692)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
4.5/5 (1912)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
4/5 (4074)
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
3.5/5 (143)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
3.5/5 (830)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
3.5/5 (901)
John Adams
From Everand
John Adams
David McCullough
4.5/5 (2542)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M L Stedman
4.5/5 (790)
CCquestion bank cc
PDF
No ratings yet
CCquestion bank cc
1 page
html-all-tags-chart
PDF
No ratings yet
html-all-tags-chart
8 pages
FYBBI Cultural Notes
PDF
No ratings yet
FYBBI Cultural Notes
5 pages
Cultural Objectives
PDF
No ratings yet
Cultural Objectives
6 pages
azhar ins journal
PDF
No ratings yet
azhar ins journal
11 pages
Assignment 3 INS
PDF
No ratings yet
Assignment 3 INS
7 pages
151b4f82-6a42-4e70-adaa-3fdbf1b25ba3
PDF
No ratings yet
151b4f82-6a42-4e70-adaa-3fdbf1b25ba3
1 page
All cp Gst
PDF
No ratings yet
All cp Gst
55 pages
Computer Laboratory Management System using PHP and MySQL - vuln 2
PDF
No ratings yet
Computer Laboratory Management System using PHP and MySQL - vuln 2
1 page
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
4/5 (45)
Little Women
From Everand
Little Women
Louisa May Alcott
4/5 (105)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
3.5/5 (109)
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Principles: Life and Work
From Everand
Principles: Life and Work
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Steve Jobs
From Everand
Steve Jobs
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Yes Please
From Everand
Yes Please
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
The Outsider: A Novel
From Everand
The Outsider: A Novel
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
John Adams
From Everand
John Adams
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
CCquestion bank cc
PDF
CCquestion bank cc
html-all-tags-chart
PDF
html-all-tags-chart
FYBBI Cultural Notes
PDF
FYBBI Cultural Notes
Cultural Objectives
PDF
Cultural Objectives
azhar ins journal
PDF
azhar ins journal
Assignment 3 INS
PDF
Assignment 3 INS
151b4f82-6a42-4e70-adaa-3fdbf1b25ba3
PDF
151b4f82-6a42-4e70-adaa-3fdbf1b25ba3
All cp Gst
PDF
All cp Gst
Computer Laboratory Management System using PHP and MySQL - vuln 2
PDF
Computer Laboratory Management System using PHP and MySQL - vuln 2
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
Little Women
From Everand
Little Women
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel