-Wreorder成员未按顺序初始化
-Wreorder (C++ and Objective-C++ only)
Warn when the order of member initializers given in the code does not match the order in which they must be executed. For instance:
struct A {
int i;
int j;
A(): j (0), i (1) { }
};
The compiler rearranges the member initializers for i and j to match the declaration order of the members, emitting a warning to that effect. This warning is enabled by -Wall.
-Wnon-virtual-dtor持有虚函数却不是虚析构
-Wnon-virtual-dtor (C++ and Objective-C++ only)
Warn when a class has virtual functions and an accessible non-virtual destructor itself or in an accessible polymorphic base class, in which case it is possible but unsafe to delete an instance of a derived class through a pointer to the class itself or base class. This warning is automatically enabled if -Weffc++ is specified.
-Wnon-virtual-dtor是一个编译器选项,用于启用警告,提示开发人员在类中定义了虚函数但没有定义虚析构函数的情况。
在C++中,当一个类有虚函数时,通常也应该有一个虚析构函数。因为如果子类对象被销毁时只调用父类的析构函数,那么可能会导致内存泄漏或者未释放资源的情况发生。
-Wnon-virtual-dtor编译器选项的作用就是让开发人员知道这种潜在的问题,并提示他们修改代码。如果一个类拥有虚函数但没有虚析构函数,编译器将会发出警告信息。