将在[-Wreorder]后初始化

will be initialized after [-Wreorder]

本文关键字:初始化 -Wreorder 将在      更新时间:2023-10-16

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

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 test {
  test(): foo(1), bar(2) { }
  int  foo;
  long bar;
};