hey, if I have to call a file.txt to open it and pick up all it's content, should I use a constructor for the name of the file?
I tried this for the constructor.
In response to your first question it LOOKS as if you are intending to put fileName into the data member called nameFile, in which case the constructor should read Countries::Countries(const string& fileName):nameFile(fileName){}
and not Countries::Countries(const string& fileName):nameFile(nameFile){}
(Be careful not to confuse nameFile and fileName!)
To be honest, I'm not quite sure what your second code fragment is doing, but I would be surprised if it compiled whilst countName is referred to in the body, but counName in the argument list: this may be a typo.
Also, you don't appear to close your input stream anywhere - I would expect to see myflux.close()
somewhere.
I would be inclined to return a list<string> from the function and let whatever called it deal with the output.
hi,
Thank you for the answer.
I will try to make the first one working.
The second code is supposed to display the content of the linked list i created.
The linked list contains the countries names that i Collected from the file "countries.txt"
I think i figured it out by removing the line #8
I don't know if it is correct, but it is working.
the overloading operator is displaying the content of my linked list