ostream manipulator class



 DEVELOP > c-Plus-Plus > ostream manipulator class

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
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
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER