foo.h
#ifndef FOO_H
#define FOO_H
class Foo
{
int fooObj1;
bool fooObj2;
public:
Foo(int input1);
};
#endif
foo.cpp
#include "foo.h"
Foo::Foo(int input1)
{
fooObj1 = input1;
// some code logic to decide the value of fooObj2 (an example)
// so I can't really do member initialization list.
fooObj2 = (fooObj1 % 2 == 0);
}
所以我正在关注一个教程,他们告诉我打开[-Weffc++]
并将警告视为错误。但是当我这样做时,请[-Weffc++]
发出警告: 'Foo::fooObj1' should be initialized in the member initialization list [-Weffc++]
和'Foo::fooObj2' should be initialized in the member initialization list [-Weffc++]
. 但是我不能在这个项目中真正做成员初始化列表。那么我该如何重新接受这个警告呢?