Hi all,
Iam trying to create a class,say, "example" and some function in it. the goal of the program is to read a array from a file and output the array elements into the another file. File contains integer data. I have given the code I tried so far. Please help me to solve it. Im just the beginner in C++. so your help and suggestions required a lot. Thank you
Header code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include<fstream>
usingnamespace std;
class example
{
public:
void intialize_array(ifstream,int);
void output_array();
ifstream in;
ofstream out;
void file_open(ifstream,ofstream);
void file_close(ifstream,ofstream);
example();
int numbers[5];
int i;
};
The underlined parameters are passed by value, so they have no effect on the arguments passed because it does not return them. To solve this, either you pass them by reference, or you return them.
For me to help you better, please post your errors.
Error 1 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\program files\microsoft visual studio 10.0\vc\include\fstream 1116
Error 2 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' c:\program files\microsoft visual studio 10.0\vc\include\fstream 890
Hi chipp and cire
So should i pass the fstreams as reference(ifstream&,ofstream&)?