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)
fooObj2 = (fooObj1 % 2 == 0);
}
So I was following a tutorial and they told me to turn on [-Weffc++]
and treat warnings as errors. But when I do that, [-Weffc++]
give a warning: 'Foo::fooObj1' should be initialized in the member initialization list [-Weffc++]
and 'Foo::fooObj2' should be initialized in the member initialization list [-Weffc++]
. But I can't really do member initialization list in this project. So how can I reslove this warning?
Aucun commentaire:
Enregistrer un commentaire