Strong Numbers using friend function in C++

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

Write a C++ program to find Strong Numbers within a range of numbers by using friend function in C++. If we declare a function int disp(T4Tutorials_Strong_Numbers); as a friend function friend int disp(T4Tutorials_Strong_Numbers); in a class class T4Tutorials_Strong_Numbers , then this function int disp(T4Tutorials_Strong_Numbers); can access the private and protected members of the class T4Tutorials_Strong_Numbers. 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_Strong_Numbers { … friend return_type function_name(arguments); … }
Output Please input the starting range of number : 1 Please input the ending range of number : 10 The Strong numbers are: 1   2

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials