From: James Dennett on
Mike Wahler wrote:
> "James Dennett" <jdennett(a)acm.org> wrote in message
> news:WfSOg.4423$8J2.4070(a)fed1read11...
>> c19h28o2 wrote:
>>> Hi,
>>>
>>> can anyone tell me what i'm doing wrong here...
>>>
>>> #include <iostream>
>>> #include <vector>
>>> #include <string>
>>> #include <sstream>
>>>
>>> using std::cout;
>>> using std::cin;
>>> using std::vector;
>>> using std::string;
>>> using std::stringstream;
>>>
>>> istream& isNumeric(istream& in);
>>>
>>> int main()
>>> {
>>> .....
>>>
>>> on the istream& isNumer.... line I get the following error...
>>>
>>> error: expected constructor, destructor, or type conversion before '&'
>>> token
>>>
>>> Thanks
>>>
>>> Michael
>> You should write std::istream, or add a using declaration
>> "using std::istream;". The compiler doesn't know what you
>> mean by a plain (unqualified) "istream".
>
> Also, note that 'std::istream' is declared by <istream>,
> which was not #included.

It's defined by <istream>, but must of necessity be
declared in <iostream>

> Most compilers will have already
> exposed 'std::istream' when <iostream> was #included, but
> this is not guaranteed by the language standard.

A definition is often included by <iostream>, but as you say,
it's not required (only a declaration is required).

> #include <istream>
> using std::istream;
>
> istream& isNumeric(istream& in);

While this only needs a declaration, its implementation
almost certainly needs a definition of std::istream,
which formally requires #include <istream>.

-- James
First  |  Prev  | 
Pages: 1 2
Prev: missing file?
Next: map string to function