Hello,
I have this annoying error 'redefinitin of ______ previoulsy declared here', and both them point to the same line.
Now I know that this can be solved by implementing guards at the beginning of .h files, but that doesn't seem to work for me now. Does anyone know what's happening here?
I wouldn't implement your templates in a source file that is included in a header file. I don't know for certain if that's what is causing your error, but I would make sure you aren't trying to compile ArrayStack.cpp, probably by renaming to something like ArrackStack.implementation or whatever. It also should not need to include its ArrayStack.h since it is just the header implementation.
As @Zhuge suggested, your problem is declaring the templated functions in a separate file. Try to move all the declarations from the .cpp file back to the .h file and it should work (unless you have other errors which I didn't really look for).
Quote from The C++ Standard Library: A Tutorial and Handbook
The only portable way of using templates at the moment is to implement them in header files by using inline functions.