Gosh I hate this message. I'm getting tired of seeing this message, finding the solution, and then forgetting all over again. Specifically, here's the message:
Code:
error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_ifstream<char,struct std::char_traits<char>
>::basic_ifstream<char,struct std::char_traits<char> >(char const *,int)" (__imp_??0?$basic_ifstream@DU?$char_traits@D@std@@@std@@QAE@PBDH@Z) referenced in function
Like I said, I've had this message before and fixed it but I just can't remeber what I did. Here's the situation for this particlar problem:
I'm writing a class (BTW, I'm writing a windowed application, so don't complain about what I've included ). Some_Class.h:
Code:
#include <windows.h>
#include <commctrl.h>
#include <string>
#include <iostream>
#include <fstream>
class Some_Class:
{
...
public:
bool SomeFunction(std::string fileName);
...
}
I define the functions in Some_Class.cpp:
Code:
#include "Some_Class.h"
bool Some_Class::Some_Function(std::string fileName)
{
std::ifstream in(fileName.c_str());
if (in.bad()) return false;
return true; //Of course I'm going to add more here, instead of just returning
}
The first line (where I declare the ifstream) is where the error is occuring. Can anyone tell me why? I've tried including all of the same things as Some_Class.h, which didn't work.
I also tried sticking this function in Some_Class.h, which did work! Can someone please explain this to me? I'm getting tired of getting this message. Thanks.