Bonjour,
Une class 'PPM' contient la fonction suivante
Read(const string& );
je voudrais la rendre en une fonction de lecture de fichier de maniere a ce que quand j'appelle Read(nomdefichier); que ca se lise d'une maniere normale.
alors je fais
Une erreur de compilation :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 #include <iostream> #incude <fstream> using namespace std; void PPM::Read(const string& fname){ ifstream fp; fp.open(fname); //ne compile pas }
quand j'indique un fichier sans variables genre: fp.open("fichier23.txt"), ca compile parfaitement.sfg:hydra23 ~/lab2a> make <- 1:03PM
g++ -g -c ppmutils.cpp
ppmutils.cpp: In member function âvoid PPM::Read(const std::string&)â:
ppmutils.cpp:12: error: no matching function for call to âstd::basic_ifstream<char, std::char_traits<char> >::open(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)â
/usr/include/c++/4.2/fstream:517: note: candidates are: void std::basic_ifstream<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]
make: *** [ppmutils.o] Error 1
Des idees ?
Partager