noob question about variables
What am I doing wrong here?
Code:
void calc_vector_sum() {
string tmp, iqfile, outname;
int ny, nx;
float data;
iqmatrix iqsum;
ifstream file ("inputfile.txt");
if (file.is_open()) {
file >> outname;
file >> ny;
file >> nx;
iqmatrix iqsum (ny,iqvector(nx));
while (file >> iqfile) {
add_data(iqfile, iqsum);
}
file.close();
cout << "iqsum.size() " << iqsum.size() << endl;
cout << "iqsum[0].size() " << iqsum[0].size() << endl;
}
else {
cout << "Could not open parameterfile" << endl;
exit(1);
}
cout << "iqsum.size() " << iqsum.size() << endl;
cout << "iqsum[0].size() " << iqsum[0].size() << endl;
return 0;
}
with these in the header
Code:
typedef complex<float> fcomplex;
typedef vector<vector<fcomplex> > iqmatrix;
typedef vector<fcomplex> iqvector;
When I print out dimensions the first time it works, second time it doesnt. How should I do to access iqsum outside the IF. I tried make it global, but didnt work for me... Any idea?
Cheers