Here, we have to define a Non-Member Function, in which we have to pass an Object to the class in C++ programming language.
What we are doing in this example?
- We declared a class named Number that has a private data member named num.
- We define a Non Member function named myFunction(), that will take two parameters 1) object to class Number and 2) an integer variable number.
Using the example, We have to supply a number (from the main() function) to the class's data member using a Non-Member Function.