Thought Leadership
Video about C++ reference parameters
My latest video blog is now available. This time I am looking at reference parameters in C/C++ and how they can reduce errors with pointer manipulation, but perhaps at the cost of code readability. You can see the video here or here:
Future video blogs will continue to look at topics of interest to embedded software developers. Suggestions for topics are always welcome via comment, email or social networking.
Comments
2 thoughts about “Video about C++ reference parameters”
Leave a Reply
You must be logged in to post a comment.
What about choosing proper names ? In my humble opinion that would be bizarre that a function called swap didn’t change its params
Or you could code in a const safe manner.
If the parameter isn’t a constant, reference or pointer, it can be changed.
It’s self documenting that swap( int &, int &) can change both parameters… Where as swap( const int &, const int &) can not change them
For complex types, non POD, the cost of an accidental deep copy, when you simply need the value makes const reference parameters crucial to high speed software development.