Parameter Passing: Difference between revisions
Content added Content deleted
m (English, clarified formal and actual parameter) |
m (→Example [[C]]/[[C++]]: Missed some grammar) |
||
Line 26: | Line 26: | ||
===Example [[C]]/[[C++]]=== |
===Example [[C]]/[[C++]]=== |
||
[[C]] and [[C++]] use only by value parameter passing. Arguments are mutable as if they were in-out, but the compiler does not store the copies back. Results also passed by copy (copy out). Where by-reference passing is needed, the [[C]]/[[C++]] deploys [[reference|referential]] types ''T*'' and ''T&'' (in [[C++]]). So when an object of the type ''T'' needs to be passed by reference, another object of either the type ''T*'' or ''T&'' is passed by value instead. Because objects in [[C++]] can be automatically converted to |
[[C]] and [[C++]] use only by value parameter passing. Arguments are mutable as if they were in-out, but the compiler does not store the copies back. Results also passed by copy (copy out). Where by-reference passing is needed, the [[C]]/[[C++]] deploys [[reference|referential]] types ''T*'' and ''T&'' (in [[C++]]). So when an object of the type ''T'' needs to be passed by reference, another object of either the type ''T*'' or ''T&'' is passed by value instead. Because objects in [[C++]] can be automatically converted to references, in many cases the difference is not noticeable. |
||
===Example [[Fortran]]=== |
===Example [[Fortran]]=== |