By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

ostream manipulator class

P: n/a
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

Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Marc Schellens" <m_*********@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
Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.