C++ 重新定义为另一种符号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12403448/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 16:15:20  来源:igfitidea点击:

Redefinition of as a different kind of symbol

c++

提问by nishantkyal

I'm creating a simple C++ header file in my xcode ios project but getting error "Redifinition of 'foo' as a different kind of symbol".

我正在我的 xcode ios 项目中创建一个简单的 C++ 头文件,但收到错误“将‘foo’重新定义为不同类型的符号”。

Here's the code

这是代码

class foo 
{
    public:
         char* getLabel(char* params);
};

回答by SingerOfTheFall

Well, the error message is pretty self-explanatory, foois already defined in the same namespace, and you are trying to re-define it.

嗯,错误消息是不言自明的,foo已经在同一个命名空间中定义了,您正在尝试重新定义它。

The part "as a different kind of symbol" suggests that the existing foois something else rather than a class definition. Changing the name will most likely solve your issue. Another way would be to put your definition of foointo another namespace. And anyway I would not recommend you to name something as fooin a realproject, no matter how small it is ;)

“作为一种不同类型的符号”部分表明存在foo是别的东西而不是类定义。更改名称很可能会解决您的问题。另一种方法是将您的定义foo放入另一个命名空间。反正我不建议你命名的东西作为foo一个真正的项目,不管它是多么小;)