i have to use my varibles in entire project. I have just defined two string varibles in a namespace and reference this header in main.cpp.
Here App.h and App.cpp:
App.h
#include <string>
#include <iostream>
using namespace std;
namespace App
{
    extern string FingerPrint;
    extern string FingerPrintID;
}
App.cpp
#include "App.h"
using namespace std;
string FingerPrint = "";
string FingerPrintID = "";
And i'm trying to use this varibles in main.cpp like this:
main.cpp
#include "App.h"
#include "Helper.h"
using namespace std;
int main()
{
    App::FingerPrint = Helper().GetFingerPrint();
    App::FingerPrintID  = Helper().GetFingerPrintID();
    cout<<"FingerPrintID: "<<App::FingerPrintID<<endl;
    cout<<"FingerPrint: "<<App::FingerPrint<<endl;
    return 0;
}
When i compile this code i get this errors:
CMakeFiles/HardwareService.dir/main.cpp.o: In function
main': /home/debian/Development/clion-workspace/app/main.cpp:19: undefined reference toApp::FingerPrint' /home/debian/Development/clion-workspace/app/main.cpp:20: undefined reference toApp::FingerPrintID' /home/debian/Development/clion-workspace/app/main.cpp:23: undefined reference toApp::FingerPrintID' /home/debian/Development/clion-workspace/app/main.cpp:24: undefined reference to `App::FingerPrint'
But if i dont use namespace and use this varibles without 'App::', it works. Like this:
App.h
#include <string>
#include <iostream>
using namespace std;
extern string FingerPrint;
extern string FingerPrintID;
App.cpp
#include "App.h"
using namespace std;
string FingerPrint = "";
string FingerPrintID = "";
main.cpp
#include "App.h"
#include "Helper.h"
using namespace std;
int main()
{
    FingerPrint = Helper().GetFingerPrint();
    FingerPrintID  = Helper().GetFingerPrintID();
    cout<<"FingerPrintID: "<<FingerPrintID<<endl;
    cout<<"FingerPrint: "<<FingerPrint<<endl;
    return 0;
}
No problem like this.
Can i use global varibles with namespace? If i can, how can i use?
 
     
    