Chapter 9. Equivalent Code?
Difficulty: 5
Can subtle code differences really matter, especially in something as simple as postincrementing a function parameter? This Item explores an interesting interaction that becomes important in STL-style code.
Describe what the following code does:
// Example 9-1 // f( a++ );
Be as complete as you can about all possibilities.
What is the difference, if any, between the following two code fragments?
// Example 9-2(a) // f( a++ ); // Example 9-2(b) // f( a ); a++;
In Question #2, make the simplifying assumption that
f()
is a function that takes its argument by value, and thata
is an object of class type that has anoperator++(int)
with natural semantics. Now what is the difference, if any, between Example 9-2(a) ...
Get More Exceptional C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.