How to declare a global class object in order to make accessible from all source files I created a template class
template<class stackElementType >
class stack {..}
I want to declare an object of this class template in main and make it global, in order to access it from another source file other than main, how to do so ?
You probably really do not want to do this, but if you must - in the file that contains main:
#include "A.h"
A a;
int main() {
...
}
and then in the files that need to access the global:
#include "A.h"
extern A a;
You will need to put the declaration of A in the A.h header file in order for this to work.