Mail Archives: djgpp/1998/04/17/21:03:28
string.h is c strings
string is c ++ strings.
Try include <string>
Might work, might not.
schuster AT eev DOT e-technik DOT uni-erlangen DOT de wrote:
>
> Hi !
> When writing some C++ code with djgpp, i've encountered the following
> problem with templates (I don't know if this is a bit off topic, but
> don't know if it's a general c++ question or a djgpp - c++ question
> either)
> Look at:
>
> #include <string.h>
> template <class T> class test
> {
> int a;
> char r[34];
> public:
> test(int integ, char* string);
> };
> template <class T> test<T>::test(int integ, char* string)
> {
> a=integ;
> strcpy(string,r);
> }
> int main()
> {
> test<int> Ttest(1,"S");
> }
>
> this works fine, but when changing to the following, the linker says
> undefined reference to
> the constructor of class <T> test. (look at the position of test<int>
> Ttest(1,"S") )
>
> #include <string.h>
> template <class T> class test
> {
> int a;
> char r[34];
> public:
> test(int integ, char* string);
> };
> template <class T> test<T>::test(int integ, char* string)
> {
> a=integ;
> strcpy(string,r);
> }
> test<int> Ttest(1,"S");
> int main()
> {
>
> }
>
> if I change it to the next all works fine. Any idea why. Is this
> normal or djgpp - c++ spezific?
> Thanks
> Michi
>
> #include <string.h>
> template <class T> class test
> {
> int a;
> char r[34];
> public:
> test(int integ, char* string){
> a=integ;
> strcpy(string,r);
> }
>
> };
> test<int> Ttest(1,"S");
> int main()
> {
>
> }
- Raw text -