User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,774 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,428 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 1688 | Replies: 0
Reply
Join Date: Oct 2004
Posts: 1
Reputation: Memory Loss is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Memory Loss Memory Loss is offline Offline
Newbie Poster

Help Difficulty understanding Object Orientated File Streaming

  #1  
Oct 20th, 2004
Well, not so much difficulty, more like I am completely stumped!

I've only been programming with c++ for a few weeks, yet I have found myself in the predicament of having a small, albeit difficult assignment to complete for university pretty soon. I was wondering if anyone could help me.

Basically, we've been given a small piece of code which controls a program that opens/closes input/output .txt files;

if (argc !=3) {

cerr << "Usage: " << argv[0] << " <input filename> <output filename>" << endl;

int keypress; cin >> keypress;

return -1;

}


The program performs three tests to determine the validity of input/output files.

I had to create a .cpp and .h file to accommodate a copy() method which performs the following functions;

Test for the existence of the input file.

Open the input file

Create the output file

Read each line of text from the input file and output the line to the output file

Return true if the file has copied or return false for any other reason


This method has to be called from the main class as highlighted above.

I'm confused about a lot of things really. How to declare an instance of secondary classes in the main class, using objects as parameters. The whole #include thing for the seperate classes. And just, you know, how file streaming works in a object orientated sense. I understand the need to #include the fstream library, but how do I know which of it's functions to use. I am running visual studio.net

If anyone could help me, or point me in the right direction I would be eternally grateful!

Thanks in advance.

Edit: I don't want a solution for this, I just need some help understanding the concepts. I feel like we haven't been taught this stuff properly (well, not at all) in lectures. This seems to aid the students with a stronger programming background, unlike myself.
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C++ Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 4:46 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC