fix cppcheck warning: Variable 'str' is assigned in constructor body. Consider performing initialization in initialization list