C++ Program Friend Function to display the reverse of a number

By: Prof. Dr. Fazal Rehman | Last updated: March 3, 2022

C++ Program Friend Function to display the reverse of a number

Write a C++ Program to display the reverse of a number using the Friend function.

If we declare a function friend void show(T4Tutorials); as a friend in a class T4Tutorials then this function friend void show(T4Tutorials); can access the private and protected members of the classT4Tutorials. 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

Enter number to reverse: 7812

The reverse of the Entered number: 2187

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials