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 appriciated :)Code:
n.m_Num = 10;
printNumber ( n );
void printNumber ( Number passStruct )
std::cout << "Number was: " << passStruct.m_Num;