gpt4 book ai didi

c++ - 如何修复链接器错误?

转载 作者:行者123 更新时间:2023-11-28 00:45:32 26 4
gpt4 key购买 nike

<分区>

函数中main':<br/>
[Linker error] undefined reference to
Binary_to_Decimal()'
[链接器错误] 未定义对“Decimal_to_Binary()”的引用
处理十进制到二进制和二进制到十进制的程序。不幸的是,我遇到了我缺乏修复知识的编译错误。如果您能帮助解决和了解该问题,我将不胜感激。
这是程序的源代码。

#include <iostream> 
#include <string>
#include <bitset>
void Binary_to_Decimal();
void Decimal_to_Binary();


int main (int argv, char argc) {
while(1<2){
int m_Choice;
std::cout << "Enter 1 - for Binary to Decimal" << std::endl;
std::cout << "Enter 2 - for Decimal to Binary" << std::endl;
std::cin >> m_Choice;
if (m_Choice == 1) {
Binary_to_Decimal();
}else if (m_Choice == 2) {
Decimal_to_Binary();
}



return 0;
}
}
void Binary_To_Decimal(){
std::string Binary_to_Decimal_cstr;
std::cout << "Please enter binary number: " << std::endl;
std::cin>>Binary_to_Decimal_cstr;
std::cout<<Binary_to_Decimal_cstr;
std::cout <<"converted to Decimal is:" << std::bitset<32>(Binary_to_Decimal_cstr).to_ulong();
std::cout << std::endl;
}

void Decimal_To_Binary(){


int Decimal_to_Binary_Var;
std::cout << "Please enter Decimal number: " << std::endl;
std::cin >> Decimal_to_Binary_Var;
std::cout << Decimal_to_Binary_Var;
std::cout << "converted to Binary is: " << std::bitset<32>(Decimal_to_Binary_Var);
std::cout << std::endl;
}

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