Posted in

Strong Numbers using friend function in C++

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

 CEO @ T4Tutorials.com
I welcome to all of you if you want to discuss about any topic. Researchers, teachers and students are allowed to use the content for non commercial offline purpose. Further, You must use the reference of the website, if you want to use the partial content for research purpose.

Leave a Reply

Contents Copyrights Reserved By T4Tutorials