Ray's playground

 

Item 5:Be wary of user-defined conversion functions.(More Effective C++)

Two kinds of functions allow compilers to perform such conversions: single-argument constructors and implicit type conversion operators. A single-argument constructor is a constructor that may be called with only one argument. Such a constructor may declare a single parameter or it may declare multiple parameters, with each parameter after the first having a default value.

An implicit type conversion operator is simply a member function with a strange-looking name: the word operator followed by a type specification. You aren't allowed to specify a type for the function's return value, because the type of the return value is basically just the name of the function. 

posted on 2011-06-09 18:00  Ray Z  阅读(201)  评论(0编辑  收藏  举报

导航