In the C++ standard, NTCTS stands for "null-terminated character-type sequence".
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 205.
Wednesday, December 30, 2009
Monday, December 28, 2009
C++98: Class Templates
Class templates must be specialized explicitly.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 209.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 209.
Saturday, December 26, 2009
C++98: Cast Operators
Although, static_cast, dynamic_cast, reinterpret_cast, and const_cast all look like templates; they are not. They are operators.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 210.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 210.
Thursday, December 24, 2009
C++98: Overloaded Operators
An overloaded operator has the same precedence as the original operator.
Reference: C++ Strategies and Tactics by Robert B. Murray. Addison-Wesley, 1993., p. 33.
Reference: C++ Strategies and Tactics by Robert B. Murray. Addison-Wesley, 1993., p. 33.
Tuesday, December 22, 2009
C++98: Class Member Operators
If the following operators are overloaded, they must be class members: =, [], (), ->
Reference: C++ Strategies and Tactics by Robert B. Murray, Addison-Wesley, 1993., p. 46.
Reference: C++ Strategies and Tactics by Robert B. Murray, Addison-Wesley, 1993., p. 46.
Sunday, December 20, 2009
C++98: Copy Constructors
A copy constructor of the following form is illegal in C++: A::A(A).The argument should be const A &.
Reference: C++ Strategies and Tactics by Robert B. Murray, Addison-Wesley, 1993., p. 60.
Reference: C++ Strategies and Tactics by Robert B. Murray, Addison-Wesley, 1993., p. 60.
Friday, December 18, 2009
C++98: Nested Classes
Nested classes can derive from each other.
Reference: C++ Strategies and Tactics by Robert B. Murray, Addison-Wesley, 1993., p. 75.
Reference: C++ Strategies and Tactics by Robert B. Murray, Addison-Wesley, 1993., p. 75.
Wednesday, December 16, 2009
C++98: Deriving a Class from an int
You cannot derive a class from an int.
Reference: "C++ Strategies and Tactics" By Robert B. Murray. Addison-Wesley, 1993., p. 192.
Reference: "C++ Strategies and Tactics" By Robert B. Murray. Addison-Wesley, 1993., p. 192.
Monday, December 14, 2009
C++98: Dangling Pointer
stringstream ss("MyString");const*p=ss.str().c_str(); makes p a dangling pointer. The invisible temporaries created from str() and c_str() live only until the last ';'.
It might look like it works, but if you add some more code following const*p=..., you may see your string corrupted. I just added stringstream ss2("Another String"); and this corrupted the data to which p points.
This kind of problem is fun (sarcasm, because it is not fun) to debug.
Reference: First-hand experience.
It might look like it works, but if you add some more code following const*p=..., you may see your string corrupted. I just added stringstream ss2("Another String"); and this corrupted the data to which p points.
This kind of problem is fun (sarcasm, because it is not fun) to debug.
Reference: First-hand experience.
Saturday, December 12, 2009
Thursday, December 10, 2009
assign()
The function assign() is a member of the following containers: vector, string, deque, and list.
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p. 37.
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p. 37.
Tuesday, December 8, 2009
STL Container Destructors
None of the Standard STL containers have virtual destructors.
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p. 37.
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p. 37.
Sunday, December 6, 2009
Memory Leaks
The following statement leaks 10 bytes of memory:
operator new(10);
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p. 51.
operator new(10);
Reference: Effective STL by Scott Meyers. Addison-Wesley, 2001., p. 51.
Friday, December 4, 2009
STL Algorithms
These STL algorithms require that their input be sorted: binary_search, upper_bound, set_union, set_difference, merge, includes, lower_bound, equal_range, set_interaction, set_symmetric_difference, and inplace_merge.
Reference: Effective STL by Scott Meyers, Addison-Wesley, 2001. p. 147.
Reference: Effective STL by Scott Meyers, Addison-Wesley, 2001. p. 147.
Wednesday, December 2, 2009
unique() and unique_copy()
The STL algorithms, unique() and unique_copy() do not require their input to be sorted. The result might be surprising though, since only duplicates that are adjacent are removed.
Reference: Effective STL by Scott Meyers, Addison-Wesley, 2001., p. 147.
Reference: Effective STL by Scott Meyers, Addison-Wesley, 2001., p. 147.
Subscribe to:
Posts (Atom)