I have a header file:
#ifndef __DATABASE_HELPER_H__
#define __DATABASE_HELPER_H__
    
class DatabaseHelper{
    public: 
        static QJsonDocument* database;
        DatabaseHelper();
        static Card* selectJSonCard(std::string cardCode);
        static void testFunctions();
        static bool isLeader(std::string cardCode);
};
#endif
QJsonDocument* DatabaseHelper::database = &(QJsonDocument());
void DatabaseHelper::testFunctions(){
    std::cout << "test" << std::endl;
}
//and so on for the others
Now, I need it to be included from two different files.
With one file is fine, it compiles, but 2 files gives me this error:
[ERROR] ./models/../utils/database_helper.h:38:16: error: redefinition of ‘QJsonDocument* DatabaseHelper::database’
   38 | QJsonDocument* DatabaseHelper::database = &(QJsonDocument());
      |                ^~~~~~~~~~~~~~
./utils/database_helper.h:38:16: note: ‘QJsonDocument* DatabaseHelper::database’ previously declared here
   38 | QJsonDocument* DatabaseHelper::database = &(QJsonDocument());
      |                ^~~~~~~~~~~~~~
./models/../utils/database_helper.h:114:6: error: redefinition of ‘static void DatabaseHelper::testFunctions()’
  114 | void DatabaseHelper::testFunctions(){
      |      ^~~~~~~~~~~~~~
./utils/database_helper.h:114:6: note: ‘static void DatabaseHelper::testFunctions()’ previously defined here
  114 | void DatabaseHelper::testFunctions(){
      |      ^~~~~~~~~~~~~~
Where the first file including this is in folder ./models/ and the other one is in ./.
My goal is to be able to access the static function from every file in which I include the header, and have just one instance of the QJsonDocument variable database.
Am I missing something? Is there a way to do it?
 
     
     
    