delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/04/23/00:04:23

From: matsibp AT fschp04 DOT fisci DOT com (Pavel Matsibekker)
Subject: B18: Template class constructor bug
23 Apr 1998 00:04:23 -0700 :
Message-ID: <353E3898.2D35B795.cygnus.gnu-win32@fschp04.fisci.com>
Mime-Version: 1.0
To: gnu-win32 AT cygnus DOT com

Hello,
    I'm having trouble running an Array class which works fine with
several other compilers on solaris and hpux. I'm trying to compile it
with gnuwin32 with negative results.
     Here's a snipped of the simplifed case Foo. It gives me the
following compiler error

C:\temp\cc0037901.o: In function 'main':
<path>/Foo.t.c:(line num): undefined reference to 'Foo(int)::Foo(int &)'

g++: Internal Compiler error : program ld got fatal signal 1

Has anyone run into this?

Below is the code for it:
Foo.h:-----
template <class T>
class Foo {
public:   // CONSTRUCTORS

   Foo(T &t);
  T *d_array_p;
    // Pointer to the array
};
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo.c -----
#include <stdlib.h>
#include <iostream.h>
#include "Foo.h"

template <class T>  Foo<T>::Foo(T &t)
{
d_array_p=&t;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo.t.c -----

#include <iostream.h>
#include "Foo.h"
int
main(int argc, char* argv[])
{
int x=5;
Foo <int>  abc(x);
return 1;
}


-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019