将在 [-Wreorder] 之后初始化

will be initialized after [-Wreorder]

当我编译我的文件时,我得到这个警告:

In file included from AsyncSQL.cpp:8:0:
AsyncSQL.h: In constructor 'CAsyncSQL::CAsyncSQL()':
AsyncSQL.h:192:10: warning: 'CAsyncSQL::m_iCopiedQuery' will be initialized after [-Wreorder]
   int    m_iCopiedQuery;
      ^

这是我的 AsyngSQL.H http://pastebin.com/u72kyuq7 那我做错了什么?

问题在于您在第 22 行的初始化列表中初始化成员的顺序,

_SQLResult(): pSQLResult(NULL), uiNumRows(0),
              uiAffectedRows(0), uiInsertID(0)

它们的出现顺序应与它们在 class 定义中出现的顺序相同。例如:

class test {
  test(): foo(1), bar(2) { }
  int  foo;
  long bar;
};