Sie sind auf Seite 1von 3

PARUL INSTITUTE OF ENGINEERING & TECHNOLOGY MCA PROGRAMME OOCP Assignments

Assignment 1 1. Briefly describe limitations of C. 2. Write a note on Object Oriented Programming. 3. Briefly explain differences between C & C++. Assignment 2 1. What is the need for const pointer? Give additional examples. 2. What is the need for pointer to const? Can you give two additional examples yourself? 3. Can you suggest a case where both pointer to const and const pointer of type <datatype> const * const <pointer> ; i.e. int const * const p= q expression is useful? 4. What is the advantage of returning a reference from the function? Can you suggest some usage of returning a reference other then what is described in the chapter? 5. What is the importance of bool variable? Pick up any program that you have written in C which uses conditional expressions. Try to incorporate bool variables in the program and then run it as a C++ program. Assignment - 3 1. What is the difference between class and struct? Write a program that illustrates the difference. 2. What is the difference between C union and a C++ Union? 3. Define a class of teacher. What will you define as private? What will you define as public in that class? Suppose the class is for providing information about teachers to students. What are the function members you would like to have in that class? 4. Take a class of cricketers of Indian Cricket team. What would be data members and function members of that class? Which of them would you like to keep as private and which of them as public? Justify your answer. 5. What is the difference between storage requirements of a class and a C struct? What is the reason for the difference? 6. Take up a class of film actors. Define few data members and a function member DisplayFilmNames() which display name of films that actor has acted into. Define that function outside the class. 7. Define a nesting class Company. Define a nested class Employee. Show how employee class can be used.

Assignment 4 1. List out the differences between C functions and C++ functions. 2. What are the advantages and disadvantages of inline functions? When inline functions are proffered over the normal function? 3. Write a macro for finding out maximum of two numbers. Use it in finding our maximum of five numbers. Rewrite the same program using inline function for finding out maximum of two numbers and discuss advantages and disadvantages of both of the approaches with respect to your program. 4. Show a case where default arguments are important. Why a single default argument function prevents the overloading of a same function without any argument? 5. How can you check if your compiler applies NRV? It is made mandatory in the standard. Check with your compiler manual how to enable or disable the NRV. 6. What is the advantage of having THIS pointer? Where can THIS pointer be useful? 7. List the differences between member and non member functions. 8. When we return a reference it is better then returning a large object as it requires more amount of context switching. It has a disadvantage also. One can unknowingly use that function in LHS with unforeseen consequences. What is the solution to that problem? 9. What is the relation to polymorphism with function overloading? 10. Give an example where it is better to have overloaded functions then default arguments. 11. Discuss the importance of friend. Give an example where friend function is a better choice then non-member function. 12. What is the difference between a normal function and a const function? Show a case where const function is more useful then normal function. 13. What is the usefulness of static functions? Compare static functions with normal functions. 14. Differentiate between private and public functions. Give one example of private function which is useful for a class. 15. How pointer to function can be defined for a class member function? List out differences between pointer to normal functions and pointer to member functions. 16. How can we define pointer to static functions? Suggest how that can be done. Test it using a small program of your choice. 17. What is the advantage of function pointers? Give an example to explain the advantage. Show the usefulness of ::* operator. 18. What is name mangling? Why it is required? 19. What is linkage specification? Explain the need for linkage specification.

Assignment 5 1. What is the need for initialization of the object using constructor? If constructors are not provided in C++ what could be the problems? 2. What do constructors do? How they are different then normal functions? 3. What is the difference between default constructor provided by compiler and default constructor provided by user? 4. Show few other cases where default constructor provided by user becomes necessary. 5. What is the need for explicit constructor? Can you provide a case where it is necessary? 6. What is the difference between a parameterized constructor and default constructor? 7. Suggest the case other then shown in the chapter where we need multiple constructors in same class. 8. What is the usefulness of default arguments in a constructor? Suggest few cases where default arguments are useful. 9. What is dynamically reinitializing an object? What is the difference between normal initialization and dynamic initialization? 10. What is the need for dynamic allocation in a constructor? Show some cases where dynamic allocation is required in the constructor. 11. Show the case where if we do not provide copy constructor, behavior of the program becomes unacceptable. 12. What are the advantages of using MIL over assignment? What are the disadvantages? 13. We may need constructor in every class that we define; but we may need destructors in few classes only. Why? 14. When will the destructors be called? What is the lifetime of an object? What is the relation of the lifetime of an object to the constructors and destructor?

Das könnte Ihnen auch gefallen