I have a program with several cpp and header. I want a common instance of one of the classes for all places needed.
What I did was to place (class Trials * currenttrial) inside another header file, initialize it in the main and include the header wherever I need to use this class.
However, I get the following error
GUI1 error LNK2005: "class Trials * currenttrial" (?currenttrial@@3PAVTrials@@A) already defined in VisualPerturbation.obj
VisualPerturbation is one of the classes including the header and using this global instance. I got this error message for several other files containing this included header.
You need to put a "extern" in front of your global variable declaration, and then define the variable in ONE .cpp file without the extern.