By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,413 Members | 999 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,413 IT Pros & Developers. It's quick & easy.

calling ifstream from another class

P: 1
Hi guys,

I'm kind of new to C++. I encountered following problem. I would like to create a class from where i can read data from files. So implemented

#include "filereader.h"

#include <fstream>
#include <sstream>
#include <iostream>

using namespace std;



bool filereader::readDataFromFile()
ifstream dataFile;"testData.dat", ifstream::in);
printf("Error: file could not be opened");
return false;
return true;

I call readDatafromFile() from MAIN.CPP, which looks like this:

#include "filereader.h"
#include <stdio.h>

int main(int argc, char **args)
filereader fr;
return 0;

But it won't work. It always tells me that i tcan't open the file. What am I doing wrong. Thanks for any help.

Nov 7 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.