Merge Failing at Compilation
Hi, I'm getting the same error for all of my defined integers:
The program is meant to read two .txt files and output them on a single one alphabetized.
ERRORS:
26 request for member `open' in `insA', which is of non-class type `int[((unsigned int)((int)SIZE1))]' |
27 request for member `fail' in `insA', which is of non-class type `int[((unsigned int)((int)SIZE1))]' |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream theAdopted("The Adopted.txt");
ifstream theOriginals("The Originals.txt");
ofstream theBigPicture("The Big Picture.txt");
int SIZE1 = 200, SIZE2 = 200;
int insA[SIZE1];
int insB[SIZE2];
int outs[SIZE1 + SIZE2];
int index1 = 0;
int index2 = 0;
int A = 0;
int B = 0;
//Retreive his family's grades.
insA.open(theAdopted);
if(insA.fail())
{
cerr << "ERROR: Cannot open" << theAdopted << ". \n";
return EXIT_FAILURE;
}
//Retreive her family's grades.
insB.open(theOriginals);
if(insB.fail())
{
cerr << "ERROR: Cannot open" << theOriginals << ". \n";
return EXIT_FAILURE;
}
//Call theBigPicture.
outs.open(theBigPicture);
if(outs.fail())
{
cerr << "ERROR: Cannot open" << theBigPicture << ". \n";
return EXIT_FAILURE;
}
//Read data his family
while (theAdopted.good())
{
theAdopted >> insA[A];
A++;
}
while (theOriginals.good())
{
theOriginals >> insB[B];
B++;
}
//Alphabetize
for(int index3 = 0; index3 < A + B; index3++)
{
if(index1 == A)
{
outs[index3] = insB[index2];
index2++;
}
else if(index2 == B)
{
outs[index3] = insA[index1];
index1++;
}
else if(insA[index1] < insB[index2])
{
outs[index3] = insA[index1];
index1++;
}
else
{
outs[index3] = insB[index2];
index2++;
}
cout << outs[index3] << endl;
}
return 0;
}
|
Your code has:
1 2 3
|
ifstream theAdopted( "The Adopted.txt" );
int insA[SIZE1];
insA.open( theAdopted );
|
insA is an array of integers. How could it have a method 'open'?
Topic archived. No new replies allowed.