Programming Techniques

Home/Programming Techniques

const a*, a* const, and const a* const, oh my!

Everyone knows how to pass a pointer to a function: void MyFunction(int*){} int* a = new a; MyFunction(a); But how do you make this const correct? (I learned this from here: http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.5) Lets start with the non-pointer const syntax: void MyFunction(const int a){} This means 'a' is passed by value, so if you change a