Well, given the prototype "void GetLastName( Name lastName )", it seems reasonable to expect that the name will be copied into lastName. So, yes. Try it and see what happens.
Well, given the prototype "void GetLastName( Name lastName )", it seems reasonable to expect that the name will be copied into lastName. So, yes. Try it and see what happens.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Well this seems like it works.
But I don't see the reason for a parameter in a getter.Code:void GetLastName(Name lastName) { strcpy(last,lastName); }
This isn't really a getter function per se. It's more like a retrieval function or something. It's a getter but because of language syntax you have to pass in an argument and have that filled in, rather than returning the value. Same thing if you'd wanted to return two values: functions are only allowed to return one value so you might have to do
since "(int, int) getTwoValues()" isn't valid.Code:void getTwoValues(int &returnValue1, int &returnValue2) { returnValue1 = 12; returnValue2 = 55; }
Like I said, you could write your particular getter without a parameter by returning a pointer instead, but if you're just learning about arrays now then the instructor might not have wanted to go into details about having to preserve the scope of the variable you're returning, etc.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
Okay I think I understand it all now! Thanks for all the help I think I would have been stuck for a long time if you didn't help! We have learned arrays just he likes making things difficult for us that's all!