gpt4 book ai didi

c++ - 警告 : declaration of ‘name’ shadows a previous local

转载 作者:太空宇宙 更新时间:2023-11-03 10:23:54 29 4
gpt4 key购买 nike

<分区>

我这里有这个非常简单的片段:

std::string testName;

if (argc < 2) {
std::string testName = "default";
}
else {
std::string testName = argv[2];
}

出于某种原因,编译器给了我 2 个警告;

warning: declaration of ‘testName’ shadows a previous local [-Wshadow]
std::string testName = "default";
^

note: shadowed declaration is here
std::string testName;
^

warning: declaration of ‘testName’ shadows a previous local [-Wshadow]
std::string testName = argv[2];
^

note: shadowed declaration is here
std::string testName;
^

我感到生疏和愚蠢,感谢您的帮助!

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com