473,385 Members | 1,838 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,385 software developers and data experts.

(help) Runtime error in ifstream/ios class

Hello,

I'm trying to fix this little class:
<code>
#include <ifstream>
#include <iostream>
#include <iomanip>

using namespace std;

class iExeStream: ifstream
{
public:
int GetDOSheader(void);
DWORD GetDword(bool);
WORD GetWord(bool);
BYTE GetByte(void);
int readPascalString(char *);
};
</code>

I'm using BC++Builder 6.
It compiles correctly, but when I launch the program it dies with a
runtime error before even show the first program screen. I know ths
behaviour is sometime caused by faults in static objects ctors, who are
executed before the program starts, but no one of the iExeStream objects
I use is static.

With BCB6 debugger, after clicking OK on the error window it opens the
"ios.h" header file??? o_O
Jan 13 '06 #1
2 2123
Massimo Soricetti wrote:
Hello,

I'm trying to fix this little class:
<code>
#include <ifstream>
#include <iostream>
#include <iomanip>

using namespace std;

class iExeStream: ifstream
{
public:
int GetDOSheader(void);
DWORD GetDword(bool);
WORD GetWord(bool);
BYTE GetByte(void);
int readPascalString(char *);
};
</code>

I'm using BC++Builder 6.
It compiles correctly, but when I launch the program it dies with a
runtime error before even show the first program screen. I know ths
behaviour is sometime caused by faults in static objects ctors, who are
executed before the program starts, but no one of the iExeStream objects
I use is static.

With BCB6 debugger, after clicking OK on the error window it opens the
"ios.h" header file??? o_O


There's nothing in the code you posted that seems like it would cause
such an error, but then again, you didn't post very much. Try to reduce
the problem to a minimal program that you could post here in its
entirety.

On the other hand, since classes default to private inheritance, your
deriving iExeStream from std::ifstream is probably poor design. Simple
composition would likely be better. See these FAQs:

http://www.parashift.com/c++-faq-lit....html#faq-24.2
http://www.parashift.com/c++-faq-lit....html#faq-24.3

Cheers! --M

Jan 13 '06 #2
mlimber ha scritto:
There's nothing in the code you posted that seems like it would cause
such an error, but then again, you didn't post very much. Try to reduce
the problem to a minimal program that you could post here in its
entirety.

On the other hand, since classes default to private inheritance, your
deriving iExeStream from std::ifstream is probably poor design. Simple
composition would likely be better. See these FAQs:


I added a public constructor and declared "public" the inheritance of
ifstream, now it works. The FAQ you mentioned are very interesting,
thank you... maybe I'm going to change something in my code, however.
Jan 14 '06 #3

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

Similar topics

4
by: Revman | last post by:
I'm having problems opening and reading from a file to test a Class. My diver main.cpp is fairly short but with a longer file open function // Project #4 -- Main/driver program #include...
3
by: Drewdog | last post by:
I am getting some error messages which I can't figure out their meaning. I have the code setup, I think it's correct but it doesn't work. My goal is to get this program to read from a data file and...
8
by: acheron05 | last post by:
Hi there, Hopefully I won't fit the stereotype of the typical student posting his assignment to be written for him, but I am quite stuck. If anyone could give me some help in how to create...
31
by: Martin Jørgensen | last post by:
Hi, I've had a introductory C++ course in the spring and haven't programmed in C++ for a couple of months now (but I have been programmed in C since january). So I decided to do my conversion...
5
by: B. Williams | last post by:
I need some assistance with random access file processing. I have a function that I would like to change from sequential file processing to random access. Thanks in advance. void...
4
by: T.Crane | last post by:
Hi, I'm new to C++, and I want to open a file, go through it line by line and pull out specific things on each line. I've written a test bit of code to try to do this. For some reason what I'm...
3
by: Stephen Torri | last post by:
Below is a class that is suppose to represent a segment of memory or a contents of a binary image (e.g. ELF executable). I have started to read Modern C++ Design and thought the best way to ensure...
12
by: Kira Yamato | last post by:
I've posted this in another thread, but I suppose I should've started a new thread for it instead. I cannot get the following short program to compile under g++: #include <iostream> #include...
6
by: priyajohal | last post by:
#include<fstream.h> #include<process.h> #include<stdlib.h> #include<conio.h> #include<string.h> #include<dos.h> #include<ctype.h> #include<stdio.h> void setup() void help();
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.