Re: how make cast from ifstream to istream in MS Visual C++

From: John Harrison (john_andronicus_at_hotmail.com)
Date: 09/07/04


Date: Tue, 7 Sep 2004 12:31:04 +0100


"ragi" <rafgiez74@interia.pl> wrote in message
news:chk57q$2tec$1@mamut.aster.pl...
> Short version of my program:
>
> ifstream File;
>
> File.open("test.txt");
> if(!File.good()) return;
>
> Func(File); <--cannot convert parametr 1 from 'std::ifstream' to
> 'std::istream'
>
>
> and declaration is:
>
> bool Func(std::istream);
>
>
> What should I do to solve these problem ?

bool Func(std::istream&);

Always pass streams by reference (or pointer) they cannot be copied.

john



Relevant Pages

  • Re: including cray pointers in fortran modules
    ...  pointer (ipt, x) ... The first layer is with the declaration of ipt and that PROGRAM ... Cray pointer at has 4 bytes of precision; ...   ...
    (comp.lang.fortran)
  • on topic to clc [Was: Banks and economy]
    ... pointer type - which I think is correct for "arrays", ... Since, as a formal parameter, char cptr[]; ... pointer to the 'completing' declaration, ...   tentative definition. ...
    (comp.lang.c)
  • RE: MIDL2039: interface does not conform to [oleautomation] attribute
    ... > compatible BSTR pointer. ... the IDL declaration produces the following warning: ... > component is that this one is passed as a pointer. ...
    (microsoft.public.win32.programmer.ole)
  • Re: const qualifier and VC6.0
    ... > emphasis is on types, while in C the emphasis is on expressions. ... When declaring pointer and reference variables, ... int &p; ... For example, the following declaration ...
    (comp.lang.cpp)
  • Re: Need help calling a function in an unmanaged DLL
    ... problem was that when the function was called, memory would get erased. ... made me suspect the VB declaration of either the structures or the function. ... Since I had the source code for the DLL, I recompiled the DLL with only the ... pointer to a structure. ...
    (microsoft.public.dotnet.framework.interop)