class person
{
private:
std::string name;
int hungerLevel;
std::string location;
int money;
public:
person() : name(""), hungerLevel(100), location(""), money(0) {}
};
When I initialize my string variables as empty strings in the default constructor using the Initializer list I get the warning "Redundant string initialization".
class person
{
private:
std::string name;
int hungerLevel;
std::string location;
int money;
public:
person() : hungerLevel(100), money(0)
{
name = "";
location = "";
}
};
However, when I initialize my strings as empty strings in the body of the constructor as demonstrated above I don't get any errors. I'm not sure if this warning is only related to IDE that I'm using or if one of them is the proper way/good practice.