delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/06/22/17:02:31

Date: Wed, 22 Jun 1994 22:32:21 +0000 (GMT)
From: Vanni Zatta <zatt00 AT laura DOT record DOT unipd DOT it>
Subject: I/O in class
To: djgpp AT sun DOT soe DOT clarkson DOT edu (Indirizzo gruppo djgpp)

I'm copiling a my program by djgpp.
I have 2 file: list.h and list.cpp
In list.h I have:
...
template <class Tipo>
class List
{ 
  public:
  friend ostream& operator << (ostream& , List<Tipo>&);
  ...
}
#include<list.cpp>;
#end


In file list.cpp I have
template<class Tipo>
ostream& operator << (ostream& s, List<Tipo>& l)
{
 ...
 ...
}

When I compile appear this message:
proval.cc(.text+6c): undefined reference to '__ls__FR7ostreamRt5List17i'

If I fuse 2 file:
template<class Tipo>
class List
{
 public:
 friend ostream& operator << (ostream& s , List<Tipo>& L)
 {
  ...
  return s;
 }

is all right and program goes. Why ? Where I wrong ?
Thanks, Vanni

- Raw text -


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