C++ LNK2019 error: Unresolved external symbol
C++ LNK2019 error: Unresolved external symbol
我在 class 的指定实验室的程序中遇到问题 building/compiling。我把代码拿给我的教授看,她只看了一眼就说她也不知道是什么导致了错误。如果我错过了直接回答这个问题的上一个问题,我深表歉意。
错误:
error LNK2019: unresolved external symbol "void __cdecl get_streams(class std::basic_ifstream<char,struct std::char_traits<char> > &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?get_streams@@YAXAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@2@@Z) referenced in function _main
这是我目前的一些程序:
Class声明:
void const get_streams(ifstream& ins, ofstream& ous);
主要功能:
int main( )
{
ifstream ins;
ofstream ous;
AltMoney m1, m2, sum, difference;
get_streams(ins, ous);
read_money(ins, m1);
cout << "The first money is:";
write_money(ous, m1);
read_money(ins, m2);
cout << "The second money is:";
write_money(ous, m2);
sum = m1 + m2;
cout << "The sum is:";
write_money(ous, sum);
difference = m2 - m1;
cout << "The difference is:";
write_money(ous, difference);
ins.close();
ous.close();
return 0;
}
Class定义:
void get_stream(ifstream& ins, ofstream& ous)
{
ins.open("in_file.dat");
if(ins.fail())
{
cout << "Failed to open the input file. \n";
exit(1);
}
ous.open("out_file.dat");
if(ous.fail())
{
cout << "Failed to open the output file. \n";
exit(1);
}
}
get_streams() 与 get_stream() 不同....
我在 class 的指定实验室的程序中遇到问题 building/compiling。我把代码拿给我的教授看,她只看了一眼就说她也不知道是什么导致了错误。如果我错过了直接回答这个问题的上一个问题,我深表歉意。
错误:
error LNK2019: unresolved external symbol "void __cdecl get_streams(class std::basic_ifstream<char,struct std::char_traits<char> > &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?get_streams@@YAXAAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@2@@Z) referenced in function _main
这是我目前的一些程序:
Class声明:
void const get_streams(ifstream& ins, ofstream& ous);
主要功能:
int main( )
{
ifstream ins;
ofstream ous;
AltMoney m1, m2, sum, difference;
get_streams(ins, ous);
read_money(ins, m1);
cout << "The first money is:";
write_money(ous, m1);
read_money(ins, m2);
cout << "The second money is:";
write_money(ous, m2);
sum = m1 + m2;
cout << "The sum is:";
write_money(ous, sum);
difference = m2 - m1;
cout << "The difference is:";
write_money(ous, difference);
ins.close();
ous.close();
return 0;
}
Class定义:
void get_stream(ifstream& ins, ofstream& ous)
{
ins.open("in_file.dat");
if(ins.fail())
{
cout << "Failed to open the input file. \n";
exit(1);
}
ous.open("out_file.dat");
if(ous.fail())
{
cout << "Failed to open the output file. \n";
exit(1);
}
}
get_streams() 与 get_stream() 不同....