Problème avec un ifstream
Ci-joint un simple morceau de mon programme, avec les éléments qui me posent problème :
Code:
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
|
# include <iostream>
# include <fstream>
# include <sstream>
using namespace std ;
const string input_dc = "./toto.txt" ;
int main()
{
ifstream steering ;
string in ;
steering = input_dc ;
int NbFlv(0) ;
while( getline(steering,in) )
{
if( in[0]!='*' ) NbFlv++ ;
}
steering.close() ;
cout << NbFlv << " lines counted" << endl ;
return 0 ;
} |
Et lors de la compilation j'obtiens :
Citation:
test.cxx: In function ‘int main()’:
test.cxx:15: error: no match for ‘operator=’ in ‘steering = input_dc’
/usr/lib/gcc/i586-redhat-linux/4.4.1/../../../../include/c++/4.4.1/iosfwd:81: note: candidates are: std::basic_ifstream<char, std::char_traits<char> >& std::basic_ifstream<char, std::char_traits<char> >::operator=(const std::basic_ifstream<char, std::char_traits<char> >&)
Merci de me dire ce qui ne va pas, j'ai utilisé n code similaire il y a de cela quelques temps et cela marchait très bien.