Posted in

Write a c++ program to find out the sum of an A.P. series using constructor and destructor.

Write a c++ program to find out the sum of an A.P. series using constructor and destructor.

Constructor

The constructor T4Tutorials_AP_Series() is a member function of the class T4Tutorials_AP_Series. The constructor T4Tutorials_AP_Series()has the same name as the name of its class T4Tutorials_AP_Series.

  1. When a new object T4Tutorials_AP_Series a; of the class T4Tutorials_AP_Seriesis executed, the constructor T4Tutorials_AP_Series() also executed automatically.
  2. The constructor T4Tutorials_AP_Series()has no data type. Even we can’t use void also.
  3. The constructor T4Tutorials_AP_Series()can have arguments.
  4. The constructor T4Tutorials_AP_Series()can be only public.
  5. There is no inheritance of the constructor T4Tutorials_AP_Series().

Destructor

The destructor ~T4Tutorials_AP_Series() is a member function of the class T4Tutorials_AP_Series. Destructor ~T4Tutorials_AP_Series() has the same name as the name of its class T4Tutorials_AP_Series. The tild sign ∼ is used before the name of the destructor ~T4Tutorials_AP_Series().

  • When the object T4Tutorials_AP_Series a; of the class T4Tutorials_AP_Seriesdestroyed, then the destructor ~T4Tutorials_AP_Series() also destroyed automatically.
  • One class T4Tutorials_AP_Series can have only one destructor ~T4Tutorials_AP_Series(). However, one class can have many constructors.
  • Destructor ~T4Tutorials_AP_Series()overloading is impossible.
  • The Destructor ~T4Tutorials_AP_Series()can’t have any arguments(parameters).
  • The destructor ~T4Tutorials_AP_Series()has no data type.

 

 CEO @ T4Tutorials.com
I welcome to all of you if you want to discuss about any topic. Researchers, teachers and students are allowed to use the content for non commercial offline purpose. Further, You must use the reference of the website, if you want to use the partial content for research purpose.

Leave a Reply

Contents Copyrights Reserved By T4Tutorials