Code: CS23                                                  Subject: OBJECT ORIENTED PROGRAMMING

                                                                                                                                      USING C++

Time: 3 Hours                                                                                                     Max. Marks: 100



·      Question 1 is compulsory and carries 28 marks. Answer any FOUR questions from the rest.  Marks are indicated against each question.

·      Parts of a question should be answered at the same place.



Q.1                                                                                                                                          (7 x 4)

             a.  Define the following terms

                  (i)    Inheritance

                  (ii)   Friend function

                  (iii)  Abstract class

                  (iv)  Meta class                                                                                                                 


             b.  Explain the shortcomings of Procedure oriented languages.


             c.  Define operator overloading with the help of an example.


             d.  What is pure virtual function? How it is implemented in C++?


             e.  What is a template class? Give an example to define a template member function outside a template class.


             f.   Write the specification for an exception class that stores an error number and error name. Include a constructor.


             g. Give the Stream Class hierarchy of classes used for simple input/output and file input/output. Also state the purpose of each class in the hierarchy.


Q.2       a.  Write a function that reverses a C-String (an array of characters). Use a for loop that swaps the first and last characters, then the second and next-to-last characters and so on. The string should be passed to the function as an argument.                                                                                                             (6)


             b.  Differentiate among local, static and global variable in terms of scope and life- time.        (6)


             c.  Differentiate between a member function and static member function in C++                   (6)


  Q.3     a.  Write six differences between a structure and class in C++.                                            (6)



             b.  Write a C++ program that creates a class time with two integers and in one float as hour, minute, and seconds respectively. There should be two constructors one for initializing these values to zero and other for initializing them to fixed values. In case seconds are not given, it should be automatically initialized to zero. A member function should display time in 02:45:67.05 format. There should also be member function that adds two time objects.                                                                                                                        (6)


             c.  Give the semantics (meaning) of the following declarations:                                                

                  (i)   char  **pt

                  (ii)  int (*array) [10]

                  (iii)  int *array [10]

                  (iv)  void (*funct)()

                  (v)   char (*(*X())[]) ()

                  (vi)  char (*(*X[5])()) [10]                                                                                            (6)


  Q.4     a.  What are advantages of virtual function? How to obtain dynamic polymorphism in C++ in the absence of virtual function?                                                                                                                       (6)


             b.  How is it possible to have multiple inputs and outputs in a single cin and cout statement respectively?           (6)


             c.  What is friend class? Give an example where use of friend class/function is necessary.     (6)


  Q.5     a.  Write classes in C++ to create a queue of items and display the items stored in the queue. Items may be of type integer, string, float and user defined. (Note: do not use struct in the program)            (6)


             b.  Write a class complex in C++. It has two data members of type integer one for real part and other for imaginary part. Also write functions that can overload assignment and increment operators both prefix and suffix.         (6)


             c.  What is virtual base class? Explain with the help of an example.                                      (6)


  Q.6     a.  Define the min() used in the following program segment as macro and template Function. Give the output of the program for both cases when min is macro and template function.                                  (6)

                   int main() {

                                    int elmcount=0;   int *p = &ia[0];

                                    while(min(p++, &ia[size]) != &ia[size])   ++elmcount;

                                    cout << “elemnet count : “ << elmcount << “\texpecting: “

<< size << endl;

return 0;



             b.  What is exception handling? What are the sequence of events when an exception occurs? Write a C++ program that uses exception to handle the errors caused when a stack is full or empty.                 (6)


             c.  Using stream and files write a C++ program that copy the contents of a text file to another text file. Invoke the program with two command-line arguments.                                                                  (6)


  Q.7     a.  Differentiate among private, public and protected access modifiers. Also explain their meaning when a derived class inherits from a base class using public, protected or private keywords.                   (6)


             b.  Write short notes any two of the following:

                  (i)   inline function

                  (ii)  persistence

                  (iii) Polymorphism

                  (iv) late binding                                                                                                           (12)