Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

OBJECT ORIENTED PROGRAMMING DESIGN

Rating
-
Sold
-
Pages
87
Uploaded on
24-02-2023
Written in
2022/2023

Constructors and Destructors: Purpose of Constructors and Destructors – overloading constructors – constructors with default arguments – copy constructors – calling constructors and destructors – dynamic initialization using constructors – recursive constructor. Overloading Functions: Overloading unary operators – constraint on increment and decrement operators – overloading binary operators – overloading with friend functions – type conversion – one argument constructor and operator function – overloading stream operators. Inheritance: Introduction – Types of Inheritance – Virtual base classes – constructors and destructors and inheritance – abstract classes – qualifier classes and inheritance – common constructor – pointers and inheritance – overloading member function

Show more Read less
Institution
Course

Content preview

Object Oriented Programming Design CST33 III –Semester




Subject Name: OBJECT ORIENTED PROGRAMMING DESIGN

Subject Code: CS T33




2 MARKS AND 11 MARKS FOR ALL UNITS

UNIT II




Constructors and Destructors: Purpose of Constructors and Destructors – overloading
constructors – constructors with default arguments – copy constructors – calling constructors and
destructors – dynamic initialization using constructors – recursive constructor.

Overloading Functions: Overloading unary operators – constraint on increment and decrement
operators – overloading binary operators – overloading with friend functions – type conversion –
one argument constructor and operator function – overloading stream operators.

Inheritance: Introduction – Types of Inheritance – Virtual base classes – constructors and
destructors and inheritance – abstract classes – qualifier classes and inheritance – common
constructor – pointers and inheritance – overloading member function.


PART A – 2 MARK QUESTIONS
1. Define constructor

A constructor is a special member function whose task is to initialize the objects of its
class. It is special because its name is same as class name. The constructor is invoked
whenever an object of its associated class is created. It is called constructor because it
constructs the values of data members of the class

Eg:
integer Class
{

,Object Oriented Programming Design CST33 III –Semester

……
public:
integer( );//constructo r
………
}

2. What is meant by operator overloading?

C++ has the ability to provide the operators with a special meaning for a data type. This
mechanism of giving such special meanings to an operator is known as Operator
overloading. It provides a flexible option for the creation of new definitions for C++
operators.

3. What are the operators that cannot be overloaded?

 Class member access operator (. , .*)
 Scope resolution operator (::)
 Size operator ( sizeof )
 Conditional operator (?:)

4. Define Inheritance.

Inheritance is the process by which objects of one class acquire the properties of objects
of another class. It supports the concept of hierarchical classification. For example the
bird ‘Robin’
5. What is meant by multilevel inheritance?

If a class is derived from a class, which in turn is derived from another class, is called
multilevel inheritance. This process can be extended to any number of levels.

Eg:
Base class Grand father
Intermediate
Base class Father
Derived class Child

6. List out the types of inheritance.

 Single Inheritance
 Multiple Inheritance

,Object Oriented Programming Design CST33 III –Semester

 Hierarchical Inheritance
 Multilevel Inheritance
 Hybrid Inheritance
 Multi-path Inheritance

7. What is Function Overloading?

A function with the same name performing different operations is called function
overloading. To achieve function overloading, functions should be declared with the
same name but different number and type of arguments.

8. List some of the special characteristics of constructor.

• Constructors should be declared in the public section.
• They are invoked automatically when the objects are created.
• They do not have return types
• They cannot be inherited.

9. Give the various types of constructors.

There are four types of constructors. They are,
• Default constructors – A constructor that accepts no parameters.
• Parameterized constructors – The constructors that can take arguments.
• Copy constructor – It takes a reference to an object of the same class asitself as an
argument.
• Dynamic constructors – Used to allocate memory while creating objects.
10. Define Destructor.

A destructor is used to destroy the objects that have been created by a constructor. It is a
special member function whose name is same as the class and is preceded by a tilde ‘~’
symbol. When an object goes out from object creation, automatically destructor will be
executed.
Example:
class File {
public:
~File(); //destructor declaration
};
File::~File()
{
close(); // destructor definition
}

11. List Some Of The Rules For Operator Overloading.

, Object Oriented Programming Design CST33 III –Semester


• Only existing operators can be overloaded.
• We cannot change the basic meaning of an operator.
• The overloaded operator must have at least one operand.
• Overloaded operators follow the syntax rules of the original operators.


12. Define parameterized constructor.
Constructor with arguments is called parameterized constructor.
Eg:
Class Student
{
int m, n;
Public:
Student (int x, int y)
{
m=x; n=y;
}

13. What are the characteristics of destructor?

 A destructor must be declared in the public section of a class.
 A class cannot have more than one destructor.
 It has no return type.
 It is incorrect to even declare a void return type
14. Define Copy Constructor

A copy constructor is used to declare and initialize an object from another object. It takes
a reference to an object of the same class as an argument

Eg: integer i2 (i1);
Would define the object i2 at the same time initialize it to the values of i1.


15. Define explicit constructor.
Constructor can be defined explicitly by using the keyword “explicit” is known as
an explicit constructor. The explicit constructor will be executed when we call the
constructor explicitly.

Ex:

explicit brother (string name)

{

Written for

Institution
Course

Document information

Uploaded on
February 24, 2023
Number of pages
87
Written in
2022/2023
Type
Class notes
Professor(s)
Swathilakshmi
Contains
All classes

Subjects

$8.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
vigneshsivakumar

Get to know the seller

Seller avatar
vigneshsivakumar Sri Manakula Vinayagar Engineering College
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 year
Number of followers
0
Documents
7
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions