my project folder contains two projects. The first one includes a gbArray class which is responsible for array handling. This project is build as DLL. The second project uses that DLL and its implemented classes.
At first I had the following problem:
I've tried to make the class much more flexible by using templates. At first that does not work, I got a linker error, that means, I have to define template methods in my header file. At this point the methods I used as templates are defined in my header class and the declaration is in my cpp file. I searched for the right solution and on some websites I read, that I have to implement the template method declaration also in my header file.
After this steps I got a new error:
1 2 3
gbarray.h(64): error C2491: 'gbArray<T>::gbArray': Definition von Funktion für dllimport nicht zulässig
gbarray.h(77): error C2491: 'gbArray<T>::~gbArray': Definition von Funktion für dllimport nicht zulässig
gbarray.h(89): error C2491: 'gbArray<T>::operator []': Definition von Funktion für dllimport nicht zulässig
In fact, dllimport means you're importing your data from a DLL (For this reason, you cannot provide your own function bodies as they will be taken from DLLs).
You should avoid importing and exporting template classes anyways, because it's impossible to do so as they're calculated on a per-instance basis.