CPP Question Bank
CPP Question Bank
2 Marks Questions
• Define constructor.
• What is destructor?
3 Marks Questions
• Explain memory allocation for objects with non-static and static data members.
• Explain static data member and static member function with example.
4 Marks / Programs
• Write a C++ program to create a class containing two data members, accept, display and
swap numbers using call by reference.
• Write a C++ program to create a class Book (B_id, B_name, B_Author, B_Publication) to
accept and display book info, and count number of books using static data member.
• Design a C++ class with a function display() and count number of times display() is called (use
static data member).
• Write a C++ program to read a text file and count characters, words, and lines.