Search code examples
c++lnk2019

C++ LNK2019 error: Unresolved external symbol


I'm having issues building/compiling my program for an assigned lab in class. I showed the code to my professor and in just glancing over it she said she too couldn't tell what was creating the error. My apologies if I missed a previous question that directly answered this.

Error:

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

This is some of my program so far:


Class Declaration:

void const get_streams(ifstream& ins, ofstream& ous);

Main Function:

 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 Definition:

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);
    }
}

Solution

  • get_streams() is not the same as get_stream()....