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

By: Prof. Dr. Fazal Rehman | Last updated: April 23, 2020

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

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials