| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"Marc Schellens" |
| Date: |
19 Nov 2003 05:29:32 AM |
| Object: |
ostream manipulator class |
Why I get for the following code the following error?
template <typename T>
class Auto {
T flt;
public:
Auto( const T f): flt( f)
{}
friend ostream& operator<<(ostream& os, Auto& a)
{
if( abs(flt) >= 100000) os << scientific; else os << fixed;
return os << flt;
}
};
str.hpp: invalid use of member `Auto<T>::flt'
Thanks,
marc
.
|
|
| User: "Victor Bazarov" |
|
| Title: Re: ostream manipulator class |
19 Nov 2003 09:43:48 AM |
|
|
"Marc Schellens" <m_schellens@hotmail.com> wrote...
Why I get for the following code the following error?
template <typename T>
class Auto {
T flt;
public:
Auto( const T f): flt( f)
{}
friend ostream& operator<<(ostream& os, Auto& a)
{
if( abs(flt) >= 100000) os << scientific; else os << fixed;
This is a _friend_ (i.e., non-member) function. What's 'flt'
here? Don't you mean to use 'a.flt'?
return os << flt;
}
};
str.hpp: invalid use of member `Auto<T>::flt'
HTH
Victor
.
|
|
|
|

|
Related Articles |
|
|