Hi.
I am using a class and an application using it.When I have my class implementation and interface in one file,every thing is OK;but as soon as I put them in two separated files, I get this error:
[Linker error] undefined reference to `ClassName::ClassMemberFunc()'
What kind of application are you creating is it a DLL or an EXE ?
because from the error it seems that you dont have not written winmain in your executable file.
Because when I copied your above code and tried it worked perfectly fine with the main added in the third file.
#include "ClassFile.h"
using namespace std;
int main()
{
ClassName N;
N.ClassMemberFunc();
}
So in my opinion you are trying to build an executable and have not written any main or winmain in that.
Ok can you please again tell me your application strucutre.
according to me you should be having :
1. ClassFile.h -> Containing class declaration
2. ClassFile.cpp -> containing implementation of each member function of class
3. <Somefile>.cpp -> Where this main resides
Also what kind of application you have choosen to create from the app wizard of VC++ i.e. console app or windows app ?
I have got these 3 files you mentioned and I am using Dev-c++ to write a simple .cpp application ,and actually this is a console app.I tried it in VC++(console app) and I got "error LNk2019".
It has to do with your project settings because LNK2019 means unresolved external symbol.
It seems that this has to do with your project settings in VC++ and if you can go back to vc++ and check that all three files are added in project.
i.e. ClassFile.h, ClassFile.cpp and <ThirdFileWithMain>.cpp
because chances are you have included ClassFile.h in <ThirdFileWithMain>.cpp but have not added them to the project which means that compiler is able to deduce the the declaration of the function and class but Linker is not able to find the definition of these functions and classes.
Check that all the files should be in path, and should be included in project.