0% found this document useful (0 votes)
127 views

Opp C++ Assignment 3

Inheritance allows using pre-defined code from parent classes without modifying it. With inheritance, new code can be added to extend the parent class. Polymorphism means an operator or method can have different meanings depending on the context. A single method can behave differently based on the object it is acting on. Pass by value means the method gets a copy of the original value, so changes made inside the method do not affect the caller. Pass by reference means the method gets the memory address of the original value, so any changes made inside the method do affect the caller.

Uploaded by

md rg
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

Opp C++ Assignment 3

Inheritance allows using pre-defined code from parent classes without modifying it. With inheritance, new code can be added to extend the parent class. Polymorphism means an operator or method can have different meanings depending on the context. A single method can behave differently based on the object it is acting on. Pass by value means the method gets a copy of the original value, so changes made inside the method do not affect the caller. Pass by reference means the method gets the memory address of the original value, so any changes made inside the method do affect the caller.

Uploaded by

md rg
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

:Write short notes on

a) Inheritance
Answer : Inheritance:-Inheritance means using the Pre-defined Code This is
very Main Feature of OOP With the advantage of Inheritance we can use
any code that is previously created. With the help of inheritance we uses
the code that is previously defined but always Remember, We are only
.using that code but not changing that code
With the Advent of inheritance we are able to use pre-defined code and
also able to add new code. All the pre-defined code is reside into the form
of classes if we want to use that code then we have to inherit or extend
.that class
b) Polymorphism

Answer : Polymorphism is the ability to use an operator or method in


different ways. Polymorphism gives different meanings or functions to the
operators or methods. Poly, referring to many, signifies the many uses of
these operators and methods. A single method usage or an operator
functioning in many ways can be called polymorphism. Polymorphism
refers to codes, operations or objects that behave differently in different
.contexts
Differentiate between pass by value and pass by reference

Answer : When passing parameters, what it is called and what happens


can be confusing. It is less essential that you call it the correct thing
than you know exactly what is happening. It is critical to have a good
.mental model, a valid memory picture of the process

Recall that when you call a function, a chunk of memory called an


activation record is allocated. Critical to the discussion here is that this
.memory holds the formal parameter values and function local variables

.Differentiate between Constructors and Destructors


:Answer : Constructor
.Constructor is used to initialize the object
.Constructor can takes parameters/arguments .2
Constructor overloading is possible means more than one constructors .3
.can be defined in the same class
.constructor can be used to initialize the memory dynamically .4
.Constructor indirectly use the new operator to initilize the objects .5
?What are the advantages of Polymorphism? How it can be implemented
Answer : Polymorphism is the ability to exist in different forms. OOP allows
objects belonging to different data types to respond to calls of methods of
the same name, each one according to an appropriate type-specific
.behavior
Polymorphism defines the functionality of difference with a single name /
interface. Different types of actions are defined by using one entity /
method, which saves the time in investing the name of different method
names. The action is determined by the common nature of the action. For
example, adding integers and floating point values. The action is common.
One interface, and multiple methods is the concept of polymorphism
Differentiate between Containers and Iterators
Answer : Containers and iterators
If you dont know how many objects youre going to need to solve a
particular problem, or how long they will last, you also dont know how to
store those objects. How can you know how much space to create? You
.cant, since that information isnt known until run time
-The solution to most problems in object
.Describe the two basic exception handling models
Answer : Exception handling is the process of responding to the
occurrence, during computation, of exceptions anomalous or exceptional
conditions requiring special processing often changing the normal flow of
program execution. It is provided by specialized programming language
.constructs or computer hardware mechanisms
An exception is a problem that arises during the execution of a program.
:An exception can occur for many different reasons, including the following

You might also like