C++ 编译器给出了有关未定义函数引用的错误
下面是我的代码编译器对函数的未定义引用。请详细说明怎么做。为什么它会给函数isAlindrome()一个关于未定义引用的错误,该函数是布尔函数C++ 编译器给出了有关未定义函数引用的错误,c++,function,boolean,undefined-reference,C++,Function,Boolean,Undefined Reference,下面是我的代码编译器对函数的未定义引用。请详细说明怎么做。为什么它会给函数isAlindrome()一个关于未定义引用的错误,该函数是布尔函数 int main() { cout << "Please enter a string: "; cin >> input; cout<<"Vowel Count"<<vowelcount(input); while(1)
int main()
{
cout << "Please enter a string: ";
cin >> input;
cout<<"Vowel Count"<<vowelcount(input);
while(1)
{
if(isPalindrome())
{
palindrome_count++;
}
}
cout<<"palindrome_count"<<palindrome_count;
}
bool isPalindrome(string input)
{
do{
if (input == string(input.rbegin(), input.rend())) {
cout << input << " is a palindrome\n";
}
}
while(1);
}
intmain()
{
cout>输入;
cout错误消息准确地告诉您需要知道的内容。
在使用IsPalindrome之前,您的代码中没有定义它。请确保在引用它的位置(即在main上方)或函数原型上方定义它。我认为,您忘记了函数声明。因此,请将forword声明放在main()
函数上方。例如:
bool isPalindrome(string input);
确切地说,我忘记了将参数输入传递给函数。我解决了这个问题,非常感谢。您建议使用op invoke ub?O_-oYou,这是一个错误。如果未声明函数,您将得到有关未知标识符的编译器错误,而不是链接器错误。此错误表明函数已声明,但未定义。如果您查看函数定义的签名(bool isPalindrome(字符串输入)
),以及它的调用方式(isPalindrome()
)-您会注意到它们不匹配,这很可能是错误的原因。请下次发布完整的程序。您省略了main()之前的一些内容
这与问题有关