#include<iostream>
#include<fstream>
#include<string>

using namespace std;
#define months 12
#define temps 2
void getData(int [months][temps],int,ifstream);
void testcout(int [months][temps],int);





int main()
{int y=0;
string skipwrd;

int mainArray [months][temps];

ifstream in_data;
ofstream out_data;
 in_data.open ("C:\\Users\\Worker\\Desktop\\Ch09_Ex09Data.txt");
getline(in_data, skipwrd);
getline(in_data, skipwrd);
in_data>>skipwrd;

 


getData(mainArray,y,in_data);
y++;
getData(mainArray,y,in_data);

 

}








void getData(int locArray[months][temps],int x, ifstream locin_data)
{int z=0;
 

	while (z!=12)
	{
locin_data>>locArray[z][x];
z++;
	}
}




void testcout(int locArray[months][temps],int x,ifstream locin_file)
{int a=0;
int b=0;
while (a!=12)
{cout<<locArray[a][b]<<" ";
a++;
}

b=1;
a=0;
while (a!=12)
{cout<<locArray[a][b]<<" ";
a++;}
}

when I run this through, I get the error:

1>c:\program files (x86)\microsoft visual studio 9.0\vc\include\fstream(676) : error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>'

Try it now:

#include<iostream>
#include<fstream>
#include<string>

using namespace std;
#define months 12
#define temps 2
void getData(int [months][temps],int,ifstream&);
void testcout(int [months][temps],int);





int main()
{
    int y=0;
    string skipwrd;

    int mainArray [months][temps];

    ifstream in_data;
    ofstream out_data;
    in_data.open ("C:\\Users\\Worker\\Desktop\\Ch09_Ex09Data.txt");
    getline(in_data, skipwrd);
    getline(in_data, skipwrd);
    in_data>>skipwrd;




    getData(mainArray,y,in_data);
    y++;
    getData(mainArray,y,in_data);



}








void getData(int locArray[months][temps],int x, ifstream& locin_data)
{
    int z=0;


    while (z!=12)
    {
        locin_data>>locArray[z][x];
        z++;
    }
}




void testcout(int locArray[months][temps],int x,ifstream locin_file)
{
    int a=0;
    int b=0;
    while (a!=12)
    {
        cout<<locArray[a][b]<<" ";
        a++;
    }

    b=1;
    a=0;
    while (a!=12)
    {
        cout<<locArray[a][b]<<" ";
        a++;
    }
}
This article has been dead for over six months. Start a new discussion instead.