77

////////////////////////////////////////////////////////
////////////////// testHasFooBar.c /////////////////////

#include <iostream.h>
#include "HasFooBar.H"

int main()
{
	HasFooBar hfb;
	iostream in("junk.dat");
	in >> hfb;

	return 0;
}

/////////////////////////////////////////////////////////
////////////////////// HasFooBar.H //////////////////////

#include <iostream.h>

#include "Foo.H"


class HasFooBar
{   private:
	Foo<int> fb;

    friend istream& operator>>(istream& in, HasFooBar& hfb);
};

istream& operator>>(istream& in, HasFooBar& hfb)
{
	in >> hfb.fb;
	return in;
}


///////////////////////////////////////////////////////
//////////////////////// Foo.H ////////////////////////

#include <iostream.h>

template <class T>
class Foo
{
    private:
	T t; 
    
    friend istream& operator>>(istream& in, Foo<T>& f);

};


template <class T>
istream& operator>>(istream& in, Foo<T>& f)
{
	in >> f.t;
	return in;
}


[ringland@dhcppc1 BH2.1]$ g++ -v
Reading specs from /usr/lib/gcc-lib/i586-mandrake-linux-gnu/2.96/specs
gcc version 2.96 20000731 (Mandrake Linux 8.2 2.96-0.76mdk)
[ringland@dhcppc1 BH2.1]$ g++ testHasFooBar.c 
In file included from HasFooBar.H:6,
                 from testHasFooBar.c:5:
Foo.H:12: warning: friend declaration `istream &operator>> (istream &, 
Foo<T> &)'
Foo.H:12: warning:   declares a non-template function
Foo.H:12: warning:   (if this is not what you intended, make sure the 
function template has already been declared and add <> after the 
function name here) -Wno-non-template-friend disables this warning.
testHasFooBar.c: In function `int main ()':
testHasFooBar.c:10: no matching function for call to 
`iostream::iostream (const char[9])'
/usr/include/g++-3/iostream.h:230: candidates are: iostream::iostream 
()
/usr/include/g++-3/iostream.h:231:                 iostream::iostream 
(streambuf *, ostream * = 0)
/usr/include/g++-3/iostream.h:232:                 iostream::iostream 
(const iostream &)
[ringland@dhcppc1 BH2.1]$ 


