+ 1

void function

Question-Write a function read_Product_Record which accepts a reference parameter new_Product of type product read_Product_Record fills new_new_Product with values entered from the keyboard. answer- void read_Product_Record(Product & new_Product) My question is how to you determine that you use ‘void’..If i used ‘int’..... will i be wrong? I undestand we use ‘void’ if they say there is no return value,other than that i dont understand in some places where they use it

4th Oct 2017, 3:41 PM
johnson
johnson - avatar
2 Answers
+ 10
It looks like "void read_Product_Record(Product & new_Product)" is a friend function for Product class. But deciding whether you need to have a return type or not, is really depends on your program design. For more info about friend function and it's usage see the following links. [https://www.tutorialspoint.com/cplusplus/cpp_friend_functions.htm] [https://www.programiz.com/cpp-programming/friend-function-class]
4th Oct 2017, 3:52 PM
Babak
Babak - avatar
+ 1
Thanks for your input
4th Oct 2017, 8:41 PM
johnson
johnson - avatar