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

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

If we declare a function friend int show(T4Tutorials_Floyds_Triangle);as a friend in a class T4Tutorials_Floyds_Trianglethen this function int show (T4Tutorials_Floyds_Triangle a)can access the private and protected members of the class T4Tutorials_Floyds_Triangle.

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
{

friend return_type function_name(arguments);

}

 

 

Output

Add a Comment