Hey guys
I never use structs really but I was messing around with them and I discovered somthing that my book doesnt teach. The below code will not compile as I havent declared a prototype for the "printNumber" function, but that made me think, what parameter do I place in the prototype to suggest I will be passing a struct to it? I havent covered passing objects to functions yet, so I thought id try with structs before I attempted classes.
And, is it safer to pass it by reference or pointer reference?
Any help appriciatedCode:#include <iostream> struct Number { int m_Num; }; int main() { Number n; n.m_Num = 10; printNumber ( n ); std::cin.get(); return 0; } void printNumber ( Number passStruct ) { std::cout << "Number was: " << passStruct.m_Num; }