Write C++ Program to display the cube of the number upto a given integer using friend function.

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

Write C++ Program to display the cube of the number upto a given integer using friend function. C++ Program to display the cube of the number upto a given integer If we declare a function friend int show(T4Tutorials); as a friend in a class T4Tutorials then this function int show(T4Tutorials object)  can access the private and protected members of the class T4Tutorials. 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 Please enter the number: 4 cube of 1 is: 1 cube of 2 is: 8 cube of 3 is: 27 cube of 4 is: 64  

Leave a Comment

All Copyrights Reserved 2025 Reserved by T4Tutorials