Sum of the series Using Constructor in C++

Sum of the series Using Constructor in C++.

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

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

Program of Sum of the series in C++

Output

Please input the number of terms. 5

The sum of T4Tutorails_ Series is 111105.