c++ imp 03-01-2024
c++ imp 03-01-2024
1. Function Overloading
a) Define Function Overloading. Write a program to demonstrate
overloading using three versions of a function named
calculateArea() for calculating the area of a circle,
rectangle, and triangle.
2. Operator Overloading
a) Explain the need for operator overloading in C++. Why can't
all operators be overloaded?
b) Write a program to overload the + operator to add two
complex numbers.
3. Inheritance
a) What is inheritance? Explain the significance of access
specifiers in inheritance.
b) List the types of inheritance supported by C++ and explain
how inheritance is implemented with an example.
4. Virtual Functions
a) Define virtual functions and explain their necessity in
object-oriented programming.
b) Write a program to demonstrate the use of virtual functions
with a base class pointer and derived classes.
5. Templates
a) What is a Template Class? Explain its advantages. Write a
program to create a template class for a stack data structure.
b) Write a function template to find the maximum of two
numbers of any data type.
6. Exception Handling
a) Explain how exception handling works in C++ and why it is
preferred over traditional error-handling techniques like
return codes.
b) Write a program to handle a divide-by-zero exception using
try, catch, and throw.
7. File Handling
a) What is random access in file handling? Explain how it is
done in C++.
b) Write a program to read and write data to a file using
ifstream and ofstream.
c) Write a program to count the number of words in a file.
(Note: Words should be separated by single spaces.)
8. Virtual Base Class
a) What is a Virtual Base Class? What issues arise if it is
not used in programs with multiple inheritance?
9. Advanced Inheritance
a) Write a program to define a class Teacher with a virtual
function salary. Derive the class Associate_Professor and
override the salary function.
10. Additional Topics
a) Differentiate between Procedural and Object-Oriented
Programming.
b) Explain the concept of polymorphism and demonstrate it with
an example program.