Première version :
/*************** os.c */
#include <iostream>
#include "Monom.h"
ostream & operator<<( ostream & os, Monom & m ) {
os << "coef=" << m.getCoef() << ", contenu=[";
for( int i=0; i<m.getTaille(); i++ ) {
if( i==( m.getTaille()-1 ) ) {
os << m.getContenu()[i];
} else {
os << m.getContenu()[i] << ",";
}
}
os << "]";
}
/*************** os.h */
#include "Monom.h"
ostream & operator<<(ostream & os, Monom & m);
/*************** compilation */
[toto@chimaira work]$ make
g++ ./src/Monom.c -c
g++ ./src/os.c ./bin/Monom.o -c
src/os.c:15: error: erreur de syntaxe before `&' token
src/os.c:19: error: `m' was not declared in this scope
src/os.c:19: error: erreur de syntaxe before `;' token
src/os.c:19: error: erreur de syntaxe before `++' token
src/os.c:27: error: erreur de syntaxe before `<<' token
make: *** [r_os] Erreur 1
Seconde version :
/*************** os.c */
using namespace std;
#include <iostream>
#include "Monom.h"
ostream & operator<<( ostream & os, Monom & m ) {
os << "coef=" << m.getCoef() << ", contenu=[";
for( int i=0; i<m.getTaille(); i++ ) {
if( i==( m.getTaille()-1 ) ) {
os << m.getContenu()[i];
} else {
os << m.getContenu()[i] << ",";
}
}
os << "]";
}
/*************** os.h */
idem que première version
/*************** compilation */
[toto@chimaira tp02]$ make
g++ ./src/Monom.c -c
g++ ./src/os.c ./bin/Monom.o -c
g++: ./bin/Monom.o: fichier d'entrée d'édition de liens n'est pas utilisé parce l'édition de lien n'a pas été faite
ar -ru bib.a ./bin/*.o
ar: création de bib.a
g++ ./src/main.c ./lib/*.a -o Monom
In file included from src/main.c:14:
src/os.h:15: error: erreur de syntaxe before `&' token
src/main.c: Dans function « int main() »:
src/main.c:86: error: no match for 'operator<<' in 'std::cout << m'
/usr/include/c++/3.3.3/bits/ostream.tcc:63: error: candidates are:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ostream<_CharT,
_Traits>&(*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char,
_Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:74: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_ios<_CharT,
_Traits>&(*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits
= std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:86: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char,
_Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:122: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(long int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:156: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:98: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(bool) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:178: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(short int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:189: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:193: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:204: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(unsigned int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:181: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(long long int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:216: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:241: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(double) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:219: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(float) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:265: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(long double) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:289: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(const void*) [with _CharT = char, _Traits =
std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:313: error:
std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT,
_Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT =
char, _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:491: error:
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:486: error:
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, const signed char*) [with _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:616: error:
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, const char*) [with _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:572: error:
std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with
_CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:452: error:
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:447: error:
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, signed char) [with _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/bits/ostream.tcc:512: error:
std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char,
_Traits>&, char) [with _Traits = std::char_traits<char>]
/usr/include/c++/3.3.3/ostream:436: error:
std::basic_ostream<_CharT, _Traits>&
std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT =
char, _Traits = std::char_traits<char>]
make: *** [ALL] Erreur 1
Ca c'est de l'erreur ! :-D
Je tenterais plutôt une mise à jour de GCC vers 3.4.3 (enfin j'espère).
Vu que je ne sais pas comment desinstaller proprement gcc (j'ai été sur le site, et j'ai lu qu'il n'y avait pas de script de desinstallation, dù à des trous de securités).
Voilà, là je tente avec yum. Et j'ai plein d'erreurs de serveurs qui ne sont pas joingnables. Il y a-t-il un fichier yum.conf à jour (j'ai déjà pris celui sur ce site) ?
Merci.
++