C ++ Assignment 2
Note - This assignment contains 2 marks questions and 4 marks
questions. you have to write in assignment notebook properly. for 4
marks questions write answers in 3 pages and for 2 marks write within 8
to 10 lines.
Answer should contain
1. Theory
2. Syntax
3. Diagram
4. Example (C++ Code)
5. Explanation of example
Last date of submission – 18/05/2022
2 marks questions
1) Give any four special characteristics of Constructor. ( 2 mks)
2) What is Friend Function (2 mks)
3) What is Constructor ?
4) What is Destructor
5) What is default constructor?
6) How to access static function?
4 marks questions
1) Explain how to define a member function outside a class definition
and inside a class definition with the help of suitable example.
2) What is Constructor ? Explain Dynamic Constructor with the help
of suitable example.
3) Create a class student having following members :
– Rollno
– Name
– Percentage
Write necessary member function to accept student details and
display details along with class obtained depending on percentage.
4) Explain special characteristics of static member variable and also
explain when do we declare a member of a class static with
the help of suitable example(Note for answer refer class notes )
5) What is Destructor ? Describe the importance of destructors with
the help of suitable example.
6) What is Object ? Explain array of object with the help of suitable
example.
7) Explain Parameterized Constructor with the help of suitable
example.
8) Write a C++ program using class with data members bookid and
bookname. Write member functions to accepts and display book
details. Count the number of books accepted and display the
total numbers of books. (Use static data member for maintining
book count.)
9) Define a class cricket, include data member player code, player
name, no_of_innings, total_runs. Write a member function :
(i) To accept information of a player.
(ii) To display information of a player.
(iii) Search details of a given player using player_code.
(Use array of objects)
10) Write a C++ program to calculate area of a triangle, circle and
rectangle using function overloading.
11) What is the difference between constructor and destructor.
12) What is friend function? Write characteristics of friend function.( Note for
answer refer class notes)
13) Write a C++ program to create a class ‘space’ that contains x, y, z, as
integer data members. Write necessary definition to use copy constructor
to copy one object to another (Use Default and parameterised constructor
to initialize the appropriate objects).
14) Explain parameterised and Dynamic constructor with suitable example.
16) What is constructor? Explain copy constructor with the help of suitable
example.
17) Define a class Employee, include data member emp-no, emp-name
Emp-address & emp-sal.
Write a member function.
i) To accept information of a employee.
ii) To display information of a employee.
iii) Search details of a given employee using emp-no.
(use array of objects).
19) Explain the use of new and delete operator with the help of suitable
example.
20) Explain with suitable example static data member and static member
function.
21) Write a C++ program to find maximum of two integer numbers of two
different classes using friend function. Write a C++ program to find maximum of
two integer numbers of two
different classes using friend function.
22) What is Constructor ? List the types of Constructor.
23) Write a C++ Program to find out minimum of two integer numbers
of two different classes using friend function.
24) What is Destructor ? Describe importance of destructors with
the help of suitable example.
25) Explain how member functions of a class can be defined in C++,
with the help of suitable example.
26) Write a c++ program to accept product details(pno,pname,price) of five products.Display product
name with highest price.