C++:有两个相同的函数,一个给出错误。怎么了?
C++: With two identical functions, one gives an error. What is happening?
发生了一些奇怪的事情。使用 MVS 2013.
Filename.cpp
#include "Functions.h"
int main()
{
introInformation();
introInformation2();
}
Functions.cpp
void introInformation()
{
//A bunch of couts telling the user how to play the game.
}
void introInformation2()
{
//A bunch of couts telling the user how to play the game.
}
当 introInformation2() 在 main 中调用时。 MVS 给出错误:'introInformation2':找不到标识符。但为什么只有第二个?一切似乎都一样。
奇怪的是,当我在 main 之上为 introInformation2() 做一个函数声明时,一切正常。但同时没有introInformation()的声明。
我注意到,如果我将 introInformation() 的名称更改为 introInformation1()(是的,在函数调用和定义中),我会得到同样的错误。好像MVS设置在以前的名字上。
我有点怀疑这是因为我复制粘贴了这个原始项目并在不更改粘贴项目的文件夹名称的情况下进行了可能的更改。该新项目已被删除。
我同意 Vlad、Christian Hacki、Jarod42 和 kiviak 的观点。
检查 Functions.h 的内容很可能会显示 introInformation() 已声明,但 introInformation2() 尚未声明。
发生了一些奇怪的事情。使用 MVS 2013.
Filename.cpp
#include "Functions.h"
int main()
{
introInformation();
introInformation2();
}
Functions.cpp
void introInformation()
{
//A bunch of couts telling the user how to play the game.
}
void introInformation2()
{
//A bunch of couts telling the user how to play the game.
}
当 introInformation2() 在 main 中调用时。 MVS 给出错误:'introInformation2':找不到标识符。但为什么只有第二个?一切似乎都一样。
奇怪的是,当我在 main 之上为 introInformation2() 做一个函数声明时,一切正常。但同时没有introInformation()的声明。
我注意到,如果我将 introInformation() 的名称更改为 introInformation1()(是的,在函数调用和定义中),我会得到同样的错误。好像MVS设置在以前的名字上。
我有点怀疑这是因为我复制粘贴了这个原始项目并在不更改粘贴项目的文件夹名称的情况下进行了可能的更改。该新项目已被删除。
我同意 Vlad、Christian Hacki、Jarod42 和 kiviak 的观点。 检查 Functions.h 的内容很可能会显示 introInformation() 已声明,但 introInformation2() 尚未声明。