Here is how to fix it:
add the following before the definition of the class:
template<class t> class Matrix;
template<class T> ostream& operator<<(ostream &, const Matrix<T>&);
template<class T> istream& operator>>(istream &, Matrix<T>&);

Thanks,
Andrew Pinski



On Thursday, Sep 19, 2002, at 23:29 US/Pacific, Justin C. Walker wrote:

> I am diddling with a pile of C++ code that hasn't gotten any better.   
> Here is one example of the problems I'm trying to work through.  I  
> suspect that it relates to differences between the C++ compilers of  
> days gone by, and those active today.
>
> I have a header file (matrix.h) that declares a template:
>
> template<class T>
> class Matrix {
> public:
>   //...
>   friend ostream& operator<< <> (ostream&, const Matrix<T>&);
>   friend istream& operator>> <> (istream&, Matrix<T>&);
>   //...
> };
>
> and when I use the declaration
>
>     Matrix<intmod> Tl;  // line 34
>
> in a program, I get this as output (gcc3, 1151, 10.1.5):
>
> matrix.h: In instantiation of `Matrix<intmod>':
> test.cc:34:   instantiated from here
> matrix.h:142: template-id `operator>><>' for `std::basic_istream<char,
>    std::char_traits<char> >& operator>>(std::basic_istream<char,
>    std::char_traits<char> >&, Matrix<intmod>&)' does not match any  
> template
>    declaration
> matrix.h:141: template-id `operator<< <>' for `std::basic_ostream<char,
>    std::char_traits<char> >& operator<<(std::basic_ostream<char,
>    std::char_traits<char> >&, const Matrix<intmod>&)' does not match  
> any
>    template declaration
>
> This sure strikes me as weird, but I don't have enough time in the C++  
> saddle to make heads or tails out of it.  Does this strike a chord  
> with anyone?  Or, is there a better list to ask?
>
> Thanks for any help.
>
> Regards,
>
> Justin
>
> --
> Justin C. Walker, Curmudgeon-At-Large  *
> Institute for General Semantics        |   If you're not confused,
>                                        |   You're not paying attention
> *-------------------------------------- 
> *-------------------------------*
>
>
>

Reply via email to