T
Thomas Matthews
Hi,
In some threads, some people mentioned that variable initialization is
best performed in an initialization list.
Is there a way to initialize a variable from an istream in an
initialization list?
Example:
class My_Class
{
public:
My_Class(istream& inp);
private:
unsigned int value;
};
My_Class :: My_Class(istream& inp)
/* [1] */ : value(/* ??? */)
{ ; }
I looked at the istream class and there is no method for
inputting an integer. The extraction operator is defined as a
non-member function.
So, if it is possible to initialize from an istream in the
initialization list, what is replaces "/* ??? */" in [1] above?
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library
In some threads, some people mentioned that variable initialization is
best performed in an initialization list.
Is there a way to initialize a variable from an istream in an
initialization list?
Example:
class My_Class
{
public:
My_Class(istream& inp);
private:
unsigned int value;
};
My_Class :: My_Class(istream& inp)
/* [1] */ : value(/* ??? */)
{ ; }
I looked at the istream class and there is no method for
inputting an integer. The extraction operator is defined as a
non-member function.
So, if it is possible to initialize from an istream in the
initialization list, what is replaces "/* ??? */" in [1] above?
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book
http://www.sgi.com/tech/stl -- Standard Template Library