Strong Numbers using friend function in C++

By Prof. Fazal Rehman Shamil

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

Prof.Fazal Rehman Shamil (Available for Professional Discussions)
1. Message on Facebook page for discussions,
2. Video lectures on Youtube
3. Email is only for Advertisement/business enquiries.

Leave a Reply

Your email address will not be published. Required fields are marked *