bonjour,
pour moi, ce code est correct
il passe très bien sous VC++6 (en retirant les includes de vcl et conio ainsi que le getch)
je pencherai plutôt pour un problème d'options de compilation ou alors est-ce un bug du compilateur !
commence par retirer les includes.
A+
-------------------------------
Réponse au message :
-------------------------------
> Le problème c'est que tu utilises mal cette méthode, voici un exemple copié de la MSDN:
>
>
> // bitset_to_string.cpp > // compile with: /EHsc > #include <bitset> > #include <iostream> > #include <string> > > int main( ) > { > using namespace std; > > bitset<5> b1 ( 7 ); > > cout << "The ordered set of bits in the bitset<5> b1( 7 )" > << "\n that was generated by the number 7 is: ( " > << b1 << " )" << endl; > > string s1; > s1 = b1.template to_string<char, > char_traits<char>, allocator<char> >( ); > cout << "The string returned from the bitset b1" > << "\n by the member function to_string( ) is: " > << s1 << "." << endl; > } > > |
>
> Kaid -
kaid.fr.st>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Bonjour, lorsque je lance avec Borland C++ Builder 5, il me dit qu il ne retrouve pas la fonction to_string() alors qu elle est clairement definie dans la librairie ... tout comme la fonction to_ulong() mais qui elle ne pose pas de probleme...
> > y a un truc ki m echappe ...
> >
> >
> >
> > #include <vcl.h>
> > #include <bitset>
> > #include <conio>
> > #include <iostream>
> > #include <string>
> >
> > int main ()
> > {
> >
> > using namespace std;
> >
> > typedef bitset<16> BitSet ;
> >
> > BitSet b;
> > int d;
> >
> > cout << " type a number ";
> > cin >> d ;
> > b |= d;
> > cout << b << endl; // results in 00000101
> >
> > string str ;
> > str = b.to_string();
> >
> > unsigned long ul ;
> > ul = b.to_ulong();
> >
> >
> >
> > getch();
> > return 0;
> > }
> >
> >
> > [C++ Error] manip_bit.cpp(28): E2285 Could not find a match for 'bitset<16>::to_string<charT,traits,Allocator>()'
>