Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 62 - 63 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 62

C & C Plus Plus
Edit

Describe in Detail

Essay▾

Find the output of the following program

  1. classsome
  2. {
  3.     public:~some()
  4.     {
  5.         cout"some's destructor"endl;
  6.     }
  7. };
  8. voidmain()
  9. {
  10.     somes;
  11.     s.~some();
  12. }

Explanation

  • In the program
Table Showing the Program
  1. classsome
  2. {
  3.     public:~some()
  4.     {
  5.         cout ≪ “somesdestructor” ≪ endl;
  6.     }
  7. };
  • Define the class some
  • In the class define the ~some () function
  • In the function cout prints the “some՚s destructor”
  1. voidmain()
  2. { 
  3. somes; s.~some();
  4. }
  • Destructors can be called explicitly.
  • Here ‘s. ~some () ’ explicitly calls the destructor of ‘s’ .
  • When main () returns, destructor of s is called again.

Question 63

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What do you mean by inheritance?

Explanation

Understanding of Inheritace
  • A class when it derives properties and characteristics from another class is called inheritance.
  • It is one of the most important feature of object-oriented programming.
  • Sub Class:

    The class that inherits properties from another class is called sub class or derived class.

  • Super class:

    The class whose properties are inherited by sub class is called base class or super class.

  • Inheritance is a technique of code reuse.
  • Provides possibility to extend existing classes by creating derived classes.

Inheritance Syntax:

class DerivedClass: accessSpecifier BaseClass

Developed by: