this is the code I write (followed by errors):
# include <stdio.h> // standard input output
# include <stdlib.h> // standard library
# include <fstream.h> // for file functions
# include <time.h> // for getting time
# include <math.h> // mathematical
# include <string.h> // string utilities
# include <iostream.h> // for i/o
# include <string>
class distanza{
private:
public:
distanza();
};
distanza::distanza()
{
ifstream fdati("c:\\tabelladistanze.txt", ios::nocreate);
if(!fdati) {cout<<"errore\n"; exit(1);}
else cout<<"file "<<fdati<<" aperto\n";
std::string str;
int x1,x2;
float f;
fdati>>str;
cout<<str;
}
void main()
{
distanza d();
}
---------------------------
--------------------Configuration: distanze - Win32
Debug--------------------
Compiling...
distanze.cpp
C:\Documents and Settings\...\codice_cpp\distanze.cpp(38) : error C2679:
binary '>>' : no operator defined which takes a right-hand operand of type
'class std::basic_string said:
' (or there is no acceptable conversion)
C:\Documents and Settings\....\codice_cpp\distanze.cpp(39) : error C2679:
binary '<<' : no operator defined which takes a right-hand operand of type
'class std::basic_string said:
' (or there is no acceptable conversion)
Error executing cl.exe.
distanze.obj - 2 error(s), 0 warning(s)
-------------------------------
I tied to read only the string ... if I try to read string and numbers the
error increase!
Thank you for your help.
Mario.