Inheritance
Inheritance
Inheritance
5. Write a C++ program to declare a class ‘College’ with data members as name and college
code. Derive a new class ‘student’ from the class college with data members as sname and
roll no. Accept and display details of one student with college data.
Class : Teacher
Class : Student datamember
datamember : Name
: sname rollno.
empid
Class : Info
7. Write a C++ program to implement following inheritance. Accept and display data for one
programmer and one manager. Make display function virtual.
8. Write C++ program for following multilevel inheritance. Accept and display data for one car
with all details./ Explain multilevel inheritance with an example
Class : Carmanufacturer
datamember : Name
Class : Carmodel
Class : Car
Science Maths
Phy marks Alg marks
Chy marks Geo marks
Result
Total
14. Write a program to implement inheritance as shown in figure No. 2. Assume suitable
member function. Accept and display data of one Teacher and one Officer
Staff
Code
Teacher Officer
Subject Grade
15. What is multilevel inheritance? Draw the diagram to show multilevel inheritance. using
classes with data member and member function(2m)
16. Write a program to implement single inheritance from the following Refer Figure No. 1/
Write a program on single inheritance.
17. Write a program to implement the following hierarchy using suitable member functions.
Refer Figure No. 2
Pointer
20. Explain reference and dereference operators w.r.t. pointer(2m)
21. List two memory management operators available in C++. Also state its use.
22. Write a C++ program to declare a class train with members as train no and name. Accept and
display data for one object of train. Use pointer to object to call functions of class.
23. Describe ‘this’ pointer in C++ with an example
24. Write a program to declare a class ‘item’ containing data members as ‘item_name’, ‘code’,
‘price’. Accept and display the information for one object using pointer to that object
25. State the advantages of pointer.
26. Write a program to declare a class ‘book’ containing data members as ‘title’, ‘author-name’,
‘publication’, ‘price’. Accept and display the information for one object using pointer to that
object
27. Give meaning of following statements(2m)
int * ptr, a = 5;
ptr = & a ;
cout << * ptr ;
cout << (* ptr) + 1
Polymorphism
28. With suitable example, describe effect of ++ and – – operators used with pointer in pointer
arithmetic.
29. Write a C++ program to swap two integer numbers and swap two float numbers using
function overloading. (Hint : overload swap function)
30. Write a C++ program to overload binary operator ‘+’ to concatenate two strings.
31. Write a program to overload the ‘—’ unary operator to negate the values
32. Define polymorphism with it’s types
33. Explain the rules of virtual function
34. State the need of virtual function in C++.
35. Explain abstract class with suitable example.
36. Differentiate between compile time polymorphism and run time polymorphism.
37. Describe the concept of virtual base class with suitable example.
File Operations
38. Write a C++ program to count number of spaces in text file
39. Write a C++ program to append data from abc .txt to xyz .txt file
40. Write a C++ program to write ‘Welcome to poly’ in a file. Then read the data from file and
display it on screen.
41. Give the syntax and use of fclose( ) function.(2m)
42. Write a C++ program for write into a file using file operations
43. Write a program for get and put functions
44. Write a program for closing a file.
45. List c++ stream classes along with their function. (any two classes)
46. Explain ios :: app and ios :: in flags
47. Write a C++ program to copy the contents of a source file student 1.txt to a destination file
student 2.txt using file operations
48. Write a program to count the number of lines in file