473,322 Members | 1,314 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Passing istream to a function

Hey, I'm trying to pass an open stream to a function so that data can
be read from it, so I that I don't have to keep opening and closing
streams all the time.

Anyway, the function definition is roughly this:

bool xCheckByteCode(istream & fsXSprite)
When I try to compile this, however, I get the following error message:

`istream' was not declared in this scope
What am I doing wrong here?

Cheers,
~Joey~

Nov 21 '06 #1
7 4609
"GameFreak7744" <Ga***********@googlemail.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
Hey, I'm trying to pass an open stream to a function so that data can
be read from it, so I that I don't have to keep opening and closing
streams all the time.

Anyway, the function definition is roughly this:

bool xCheckByteCode(istream & fsXSprite)
When I try to compile this, however, I get the following error message:

`istream' was not declared in this scope
What am I doing wrong here?

Cheers,
~Joey~
std::istream& ?
Nov 21 '06 #2
Jim Langston wrote:
std::istream& ?
Unfortunately no, when I tried that it informed me that " `istream' is
not a member of `std' ".

Nov 21 '06 #3
Joey Sabey wrote:
Jim Langston wrote:
>std::istream& ?

Unfortunately no, when I tried that it informed me that " `istream' is
not a member of `std' ".
#include <iostream>
using namespace std;

before your function

Nov 21 '06 #4
DragonSt0rm wrote:
#include <iostream>
using namespace std;

before your function
That is included in the main file of my project, the one that then
includes the file containing this function.
Adding it to this file, also, causes this error: ' multiple definition
of `xCheckByteCode(std::istream&)' '

~Joey~

Nov 21 '06 #5
Joey Sabey wrote:
That is included in the main file of my project, the one that then
includes the file containing this function.
Adding it to this file, also, causes this error: ' multiple definition
of `xCheckByteCode(std::istream&)' '

So you have an main.h where you do:

#include <iostream>
bool xCheckByteCode(std::istream & fsXSprite);

and then a main.cpp: with

#include "main.h"
using namespace std;

bool xCheckByteCode(std::istream & fsXSprite){
.............
}

Right ?

Nov 21 '06 #6
DragonSt0rm wrote:
So you have an main.h where you do:

#include <iostream>
bool xCheckByteCode(std::istream & fsXSprite);

and then a main.cpp: with

#include "main.h"
using namespace std;

bool xCheckByteCode(std::istream & fsXSprite){
............
}

Right ?
Not quite, as I have the #include in the .cpp, not the .h, etc. But I
have it working now.

Thanks for your time.
~Joey~

Nov 21 '06 #7
Joey Sabey wrote:
Jim Langston wrote:
>std::istream& ?

Unfortunately no, when I tried that it informed me that " `istream' is
not a member of `std' ".
Did you do

#include <istream>

or

#include <iostream>
Best

Kai-Uwe Bux

Nov 21 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sören | last post by:
Hi, I'd like advise on passing ownership of an iostream. The idea is that my factory class/function should open a file, read enough to detect file type (eg which soundfile format), then...
4
by: Thomas Matthews | last post by:
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...
6
by: csvka | last post by:
Hello, I wonder if I could pick your brains. I'm beginning to learn about C++. I have opened a file in my program and I want to read lines from it. I would like this to be done in a separate...
6
by: Jason K | last post by:
Let me preface this by saying this obviously isn't a C++ *language* issue per se; rather probably an issue relating to quality of implementation, unless I'm just misusing iostream... I wrote a...
13
by: Gianni Mariani | last post by:
What I would like to do is read bytes from a stream, any number and any time. I would like it to wait until there are any bytes to read. I want the exact same functionality as cstdio's "fread"...
3
by: KWienhold | last post by:
I'm currently writing an application (using Visual Studio 2003 SP1 and C#) that stores files and additional information in a single compound file using IStorage/IStream. Since files in a compound...
3
by: Kourosh | last post by:
Hi all, I'm trying to call a COM function from C# The function gets a paramter of type IStream in C++. I've found the type System.Runtime.InteropServices.ComTypes.IStream, however I'm not sure...
4
by: Ralf | last post by:
Hallo, I'm trying to call a COM function from C#. The function has a parameter from the type array of IStream* (IStream**). The COM component (out-proc-server (.exe)) has the following code: ...
0
by: vcquestions | last post by:
Hi. What's the most efficient way to pass streams between managed & native code. I need to pick up a stream from C# & pass it to c++/cli for some native operations in the form of IStream. I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.