Constructors call constructors are problematic.
The memory returned by the outer function, and the memory returned by the called constructor, is not a memory.
The error sample code is as follows:
Msg_log (Const Char*name,Const Char* Thread_name,Const Char*cfg_file,intType = STREAM,intLevel =msg_error): _name (name), _thread_name (Thread_name), _level (level), _type (type), LOGFP (0), _set_process (false), _set_line (false), _set_file (false) { if(cfg_file) Msg_log::cs_conf_file =Cfg_file; Init (type, level); Pthread_mutex_init (&createfile_mutex,null); } Msg_log (Const Char*name,Const Char*cfg_file,intType = STREAM,intLevel =msg_error): _name (name), _level (level), _type (type), LOGFP (0), _set_process (false), _set_line (false), _set_file (false) { Msg_log (Name, "", Cfg_file, type, level); }
Too many years did not write C + +, debug for a long time, only to find out where the problem.
Reference: http://www.cnblogs.com/chio/archive/2007/10/20/931043.html
[Development] [C + +] C + + Constructors call constructors