Unbenanntes Dokument
parents doing their child's homework
soap maker business plan | Register
-->
Home ETM FAQ Tips & Tricks [CTRL++] Pass value as constant reference if it is not changed in the function

Email Print

[CTRL++] Pass value as constant reference if it is not changed in the function

Date added:
Wednesday, 23 May 2018
Last revised:
Wednesday, 30 May 2018
Hits:
496
Rating:
 
Vote for this:
Good - Bad

Answer

 

Passing values as reference is faster than passing them as a copy (call by value, call by reference), if variables are passed as reference, the content is able to change and return to the calling function, if a function is not intended to change the content when values are passed as reference. The reference should be passed as const to prevent changes which are not intentional. This is also applicable for CONTROL.

main
{
  dyn_dyn_anytype dda;

  //fill dda with a lot of elements...;

  printData(dda);
}

printData(const dyn_dyn_anytype &dda)
{
  //print dda data...
}

 

Keywords for this item

Keywords

1 items are tagged with 3.12   1 items are tagged with 3.13   1 items are tagged with 3.14   1 items are tagged with 3.15   1 items are tagged with ALL Versions   1 items are tagged with Engineering   1 items are tagged with Installation / Configuration   4 items are tagged with OOP   6 items are tagged with Programming / Scripting   1 items are tagged with PVSS   2 items are tagged with WinCC Open Architecture   1 items are tagged with Windows  

Search FAQ


            Forgot login? | Register