string redeclaration in function, why is required?
Code:
int main(int argc, char* argv[]){
argc--;
if ( argc < 1){
cout << "Usage:" << endl << "h5inspect file.h5" << endl;
return 0;
}
//iterate *.h5 in ascending order
for (int count = 1; count <= argc; count ++){
char iterchar;
string filename = argv[count];
cout << "HDF5 \"" << filename << "\" { "<< endl;
dataset_loader dset(string(filename));
The last line of code is of interest. The string filename is already declared as a string, but the function only works when the parameter is given as "string(filename)" or "string& filename". But filename is already defined as a string; why does it still required the string 'filename' to be made a string, again?!