2068 Chaitra Regular engineering note
2068 Chaitra Regular Object-Oriented Programming IOE Pulchowk engineering note
1. What is encapsulation? What are its advantages? How can encapsulation be enforced in C++? Write a program to create a class Land Measure that reads Ropani, Ana, Paisa and Dam as data members. Write a function to pass two objects of type Land Measure and return their sum. (16 Ana - 1 Ropani, 4 Paisa = 1Ann, 4 Dam- 1 Paisa).
2. What is function overloading? Use new and delete operators to store numbers dynamically and find their average using casting operators. What are the things we should remember while using the default argument? Explain with an example.
3. What do you mean by friend function and friend class? Do friends violate encapsulation? Write a program that can store Department ID and Department name with constructors. Also, write destructor in the same class and show that objects are destroyed in reverse order of creation with a suitable message.
4. List the operators which cannot be overloaded. Why does the overloading of a binary operator with member function require only one argument? Create a class having an array as a member. Overload the index operator ([ ]) to input and display the elements in the array.
5. How do you access an overridden member of the base class from a member function in the derived class? What is the problem faced when using multipath inheritance and how is it solved. Explain with an example the order of constructor and destructor invocation during multiple inheritances.
6. What are the primary trade-offs between static and dynamic binding? What is pure virtual function? Write a function template for the function power() which has two parameters baseexp. The type of base is the parameter to the template and exp is int. If the exp is negative, then it must be converted to its positive equivalent. For example, 23and 2-3 must both return 8.
7. What is a file stream? Write a class student with roll, name, address, marks as member variables Use a member function to write a record of students in a binary file and another member function to read records from file. Write a program to search a specific record of a student using roll numbers as key from user input.
8. What are the advantages of Exception Handling over Conventional Error Handling mechanism? Explain the contracts for Exception Handling in C++with an example. Write a meaningful program to illustrating the use of both Exceptions with argument and Exception Specification for function.
0 Comments:
Post a Comment
Please don't enter any spam link in the comment box