Const References for Inputs and Non const Pointers for Outputs
This a convention that Andrew V taught us which is a good convention. Unfortunately a lot of our library code predates this convention but it’s what we should follow with new code.
Â
// A good example function showing the convention
// Inputs are given as const references
// Outputs are given using non const pointers
void FOObar(const COLstring& Input, COLstring* pOutput1, int* pOutput2)
// This is helpful since it makes it clearer when reading code which uses the
// function if a variable will be modified by the function
// For example
COLstring Input = "Life";
COLstring Output1;
int Output2;
FOObar(Input, &Output1, &Output2);
// If FOObar had used a non const reference like this
void FOObar(const COLstring& Input, COLstring* pOutput1, int* pOutput2);
// Then the calling code is less obvious
COLstring Input = "Life";
COLstring Output1;
int Output2;
FOObar(Input, Output1, Output2);
Â
If you are not yet familiar with C++ references read this guide in wikipedia.