I have two cpp files and a header file, in one visual studio 2010 c++ project, and I would like to link a ustring variable that's defined in one of the cpp files to the other through the use of extern.
This is the code I have now
\\Tmp.h
\\Declare tmp_user and tmp_pass
extern ustring tmp_user;
extern ustring tmp_pass;
\\TmpOne.cpp
\\define tmp_user and tmp_pass
#include "Tmp.h"
ustring tmp_user = username;
ustring tmp_pass = password;
\\TmpTwo.cpp
\\use the defined variables
#include "Tmp.h"
login(tmp_user, tmp_pass)
{
\\some function
}
When I execute this I get a linker error in my TmpTwo.cpp file.
error LNK2001: unresolved external symbol "class ustring tmp_user" (?tmp_user@@3Vustring@@A)
error LNK2001: unresolved external symbol "class ustring tmp_pass" (?tmp_pass@@3Vustring@@A)
If I define tmp_user and tmp_pass in my TmpTwo.cpp file I just get two separate empty files.
What am I doing wrong here?