string("AnyString").find(string("\0"), 0) != string::npos
This means a null character matches any string.
Saturday, January 30, 2010
Thursday, January 28, 2010
typedefs
If you remove 'typedef' from a valid typedef statement, you get a valid declaration.
Tuesday, January 26, 2010
This Pointer
The type of the 'this pointer' in a const member function of class C is: C const * const.
Reference: "C++ Gotchas" by Stephen C. Dewhurst, Addison-Wesley, 2002., p. 249.
Reference: "C++ Gotchas" by Stephen C. Dewhurst, Addison-Wesley, 2002., p. 249.
Sunday, January 24, 2010
Multi-dimensional Arrays
int rowcol1[][2] = {1, 2}; compiles. int rowcol2[2][] = {1, 2}; doesn't.
Reference: "C++ Gotchas" by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 19.
Reference: "C++ Gotchas" by Stephen C. Dewhurst. Addison-Wesley, 2002., p. 19.
Friday, January 22, 2010
Multilevel Pointers
A pointer to a pointer is an example of a multilevel pointer.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 25.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 25.
Thursday, January 21, 2010
C++98: dynamic_cast
When a dynamic_cast fails on a pointer, it returns 0; on a reference, it throws std::bad_cast exception.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 32.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 32.
Monday, January 18, 2010
C++98: Pointers to Inlined Functions
It is legal to have a pointer to an inlined function.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 50.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 50.
Saturday, January 16, 2010
C++98: Overloaded Functions
It is legal to take the address of an overloaded function.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 51.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 51.
Thursday, January 14, 2010
C++98: operator new
'operator new' is in the global scope, not in the std namespace.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 82.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 82.
Tuesday, January 12, 2010
C++98: Covariant Return Types
When overriding virtual function returns D*, and the overridden function returned B*, where D derives from B; then B* and D* are covariant return types.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 107.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 107.
Sunday, January 10, 2010
C++98: New Operator
'new operator' and 'operator new' are different functions.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005.p. 119.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005.p. 119.
Saturday, January 9, 2010
C++98: Complete Specialization
A complete specialization is another name for a class template explicit specialization.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 156.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 156.
Wednesday, January 6, 2010
C++98: Template Specialization
template <typename T> class X<T *> {...} is a specialization of template <typename T> class X {...}
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 196.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p. 196.
Monday, January 4, 2010
C++98: Templates
vector<int> is a class; it is not a template.
Saturday, January 2, 2010
C++98: Containers
When you use vector, you are really using vector >
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p.199.
Reference: C++ Common Knowledge by Stephen C. Dewhurst. Addison-Wesley, 2005., p.199.
Subscribe to:
Posts (Atom)