object oriented programming c++ lecture notes pdf
Lecture 21 Object-Oriented Programming
OOP lets you: Build some extensible software concisely Exploit an intuitive analogy between interaction of physical entities and interaction of software pieces It also: Raises tricky semantic and style issues that deserve careful PL study Is more complicated than functions Not necessarily worse but I\'m skeptical that all those accessor methods are |
What is OOP & how can I learn it?
There is much more to OOP to be discovered on your own or through other courses. We started our discussion of OOP with classes, which form part of the foundation of object-oriented programming. Fundamentally, a class allows us to package together related pieces of data with functions that operate on that data.
How to create a data structure in a non-object oriented language?
In non-object-oriented languages, such as C, if we wanted to create a data structure, we had a data representation (typically a struct) that was wholly separate from the functions that operated on it. For example, if we had a vector variable, we would pass it to an add () function as a parameter.
What is add function in object oriented programming?
The add function typically was not bound to, or part of, the vector variable in any way. Object-oriented programming breaks down a bit of the wall between data and functionality and unifies those concepts into classes in a way that jives with our notion of how we interact with many objects in the real world.
What is object oriented programming?
The object-oriented paradigm allows us to reflect that sort of integration in code and build programs that manipulate the state of our data in ways that really reflect our understanding of how we interact with objects in the real world. When we create a new class, we are typically also creating a new datatype.
Don't Believe the Hype
OOP lets you: Build some extensible software concisely Exploit an intuitive analogy between interaction of physical entities and interaction of software pieces It also: Raises tricky semantic and style issues that deserve careful PL study Is more complicated than functions Not necessarily worse, but I'm skeptical that all those accessor methods are
In (pure) class-based OOP:
Everything is an object Objects communicate via messages (handled by methods) Objects have their own state Every object is an instance of a class A class describes its instances' behavior Why is this approach such a popular way to structure software?
OOP can mean many things
I An ADT (private elds) Inheritance, method/ eld extension, method override Implicit this / self Dynamic dispatch Subtyping All the above (plus constructor(s)) with 1 class declaration Design question: Better to have small orthogonal features or one \\do it all" feature? Anyway, let's consider how \\unique to OO" each is. . . groups.seas.harvard.edu
Subtyping, continued
If C extends D and overrides a method of D, what restrictions should we have? Argument types contravariant (assume less about arguments) Result type covariant (provide more about result) Many \\real" languages are even more restrictive I Often in favor of static overloading Some bend over backward to be more exible I At expense of run-time checks/ca
The essence
Claim: Class-based object are: So-so ADTs Same-old record and function subtyping Some syntactic sugar for extension and override And: I A fundamentally di erent rule for what self maps to in the environment groups.seas.harvard.edu
The big debate
Open recursion: Code reuse: improve even by just changing odd Superclass has to do less extensibility planning Closed recursion: Code abuse: break even by just breaking odd Superclass has to do more abstraction planning Reality: Both have proved very useful; should probably just argue over \\the right default" groups.seas.harvard.edu
Where We're Going
Now we know overriding and dynamic dispatch is the interesting part of the expression language. Next: How exactly do we de ne method dispatch? How do we use overriding for extensible software? Revisiting \\subtyping is subclassing" Usually convenient Not necessary Not always desirable groups.seas.harvard.edu
Dispatch continued
Approach 2: Each object has 1 \\run-time tag" For new C() where C extends D, tag is C self bound to the (whole) object in method body Method call to m reads tag, looks up (tag,m) in a global table Both approaches model dynamic-dispatch and are routinely formalized in PL papers. Real implementations a bit more clever. Di erence in approaches only obs
Overriding and Hierarchy Design
Subclass writer decides what to override to modify behavior I Often-claimed unchecked style issue: overriding should specialize behavior But superclass writer often has ideas on what will be overridden Leads to abstract methods (must override) and abstract classes: An abstract class has > 0 abstract methods Overriding an abstract method makes it no
Overriding for Extensibility
A PL example: class Exp { abstract Exp eval(Env); abstract Typ typecheck(Ctxt); abstract Int toInt(); } class IntExp extends class Exp { Int i; Exp eval(Env e) { self } Typ typecheck(Ctxt c) { new IntTyp() } Int toInt() constructor(Int _i) { i } { i=_i } } groups.seas.harvard.edu
Extending the example
Now suppose we want MultExp No change to existing code, unlike ML In ML, we would have to \\prepare" with an \\Else of 'a" variant and make Exp a type-constructor In general, requires very fancy acrobatics Now suppose we want a toString method Must change all existing classes, unlike ML In OOP, we would have to \\prepare" with a \\Visitor pattern" In g
If you have MultExp extend Exp, you will copy typecheck from AddExp
If you have MultExp extend AddExp, you don't copy. The AddExp implementer was not expecting that. May be brittle; generally considered bad style. Best (?) of both worlds by refactoring with an abstract BinIntExp class implementing typecheck. So we choose to change AddExp when we add MultExp. This intermediate class is a fairly heavyweight way to us
Object Oriented Programming Using C++
LECTURE NOTES. ON. Object Oriented Programming Using C++. Prepared by. Dr. Subasish Mohapatra. Department of Computer Science and Application. |
OBJECT ORIENTED PROGRAMMING DIGITAL NOTES
Oriented Programming Encapsulation |
Object Oriented Programming
Dr. Feza Buzlaca's Lecture Notes Introduction to Object Oriented Programming. ... An object's functions called member functions in C++ typically. |
Object Oriented Programmimg with C++
OOP - Object Oriented Languages - Structure of C++ Program - Tokens LECTURE NOTES ON Object Oriented Programming Using C++ by Dr. Subasish Mohapatra |
A Static C++ Object-Oriented Programming (SCOOP) Paradigm
The object-oriented programming (OOP) paradigm offers a solution to ex- Oriented Programming (ECOOP) volume 1098 of Lecture Notes in Com-. |
Object-Oriented Programming in C++ Fourth Edition
Why Do We Need Object-Oriented Programming? Notes on Passing by Reference . ... ples in this book. With that lecture out of the way here's the syntax. |
A Complete Guide to Programming in C++
Chapter 1 gives a thorough description of the fundamental characteristics of the object- oriented C++ programming language. In addition students are |
Notes Subject: Object Oriented Programming through C++ (IT-03
Notes. Subject: Object Oriented Programming through C++ (IT-03). Class: Information Technology BSc. 2 nd year (Semester –III) |
Untitled
About the Tutorial. C++ is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C++ runs on a variety of |
Read Book Lecture Notes On Software Engineering - covid19
LECTURE NOTES ON Object Oriented Programming Using C++ Department of Computer Science and Application College of Engineering and Technology ... |
Object Oriented Programming Using C++ - College of Engineering
hybrid inheritance, role of virtual base class, constructor and destructor Object C Functions Data Features of the Object Oriented programming 1 Consult the compilers section and the manual or help included with your compiler if you Note that C++ assigns additional meaning to the symbol here is not an |
Object Oriented Programming - İTÜ
Dr Feza Buzlaca's Lecture Notes 1 Object Oriented Programming Why C++ Why C++ ▻C++ supports writing high A users manual should be also written |
OBJECT ORIENTED PROGRAMMING DIGITAL NOTES - MRCET
Introduction of Classes, Class Definition, Defining a Members,Objects,Access Control, Class Scope, Object Oriented Programming with C++ by Balagurusamy Note: Some compilers of C recognize only the first 8 characters only; because |
6096 Introduction to C++: Object-oriented programming
Introduction to C++ January 19, 2011 Massachusetts Institute of Technology Lecture 7 Notes: Object-Oriented Programming (OOP) and Inheritance |
Object Oriented Programming using C++ - dde gjust
integer object in C If fruit has been defines as a class, then the statement Note that the default return type for all function in C++ is int The following main |
Object-Oriented Programming with C++
a Class ▫ 5 Classes as User-Defined Types ▫ 6 Using Constructors How Well are ADTs Supported in C? C++ supports Object-Oriented Programming |
Introducing to Object-Oriented Programming - Indico
These lecture notes are designed to provide the basic knowledge on OOP, may be compiled with C++, that is also an OOP language, without understanding |
Notes Subject: Object Oriented Programming through C++ (IT-03
C++'s basic unit of encapsulation is the class Within a class, code or data or both may be private to that object or public Private code or data is known to and |
Introduction to C++ and Object Oriented Programming - CERN Indico
v60 – Edition for 2018 Master Course Introduction to C++ • Wide choice of OO- languages – why program in C++? I will cover a subset of these C++2011 features in this course, Note: potentially expensive, because passing large objects |
LECTURE NOTE on PROGRAMMING IN “C” - VSSUT
Compiler read the program at-a-time and searches the error and lists them If the program is error free then it is converted into object program When program size |