I'm struggling with a warning that cppcheck
(version 1.85 on a Linux machine) is reporting:
someFile.h:23:29: warning: Redundant code: Found a statement that begins with string constant. [constStatement]
const std::string OffOn[]= {"off", "on"};
^
I did some research and found that changing the statement to
const std::string OffOn[]= {std::string("off"), std::string("on")};
removes the warning. However I do not understand what's going on, and what's "bad" about my first solution. Maybe someone can explain it to me? Or give me some hints!
const std::string OffOn[]{"off", "on"};
, so=
is just unnecessary. – Honor