Write a program in C++ to print Floyd’s Triangle by using the constructor destructor.

Write a program in C++ to print Floyd’s Triangle by using the constructor destructor.

Constructor

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

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

Destructor

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

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

Output