Hi all, I just start learning c++ and I'm a little bit confused with passing parameters to function. hope you can help me out
Check the example:
to get a local copy of vec which is passed from the caller function, can I just instead writeCode://definition of a function vector<int> sub_vec( const vector<int> &vec, int val ) { vector<int> local_vec( vec ); //do operations on local_vec, ...... }in the second case, what is passed? an address? the whole object "Code:vector<int> sub_vec( vector<int> local_vec, int val) { //do operations on local_vec; ...... }
vec"? when passing parameters, what is actually processed? an assignation (then second case is illegal, cuz local_vec may not be big enough) or just an initialization?
Thanks for help



LinkBack URL
About LinkBacks




CornedBee