Sum of the series Using friend function in C++

Sum of the series Using friend function in C++.

If we declare a function int show(T4Tutorials_SERIES n) as a friend in a class T4Tutorials_SERIES; then this function show() can access the private and protected members of the class T4Tutorials_SERIES. You must know that a global function can also be declared as a  friend function of the class.

Syntax of friend function in C++

class class_name_T4Tutorials
{

friend return_type function_name(arguments);

}

Program of Sum of the series in C++

C++ Program to show the  Sum of the series Using friend function

Output

Please enter a number:

4

Hi, the sum of T4Tutorials_SERIES is:

11106

Sum of the series Using friend function in C++