Librairie probleme

cs_helena123 Messages postés 22 Date d'inscription mardi 4 mars 2003 Statut Membre Dernière intervention 25 août 2003 - 30 juil. 2003 à 11:19
cs_vieuxLion Messages postés 455 Date d'inscription samedi 26 octobre 2002 Statut Membre Dernière intervention 6 avril 2004 - 30 juil. 2003 à 18:22
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
#include <conio>
#include
#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>()'

2 réponses

cs_Kaid Messages postés 949 Date d'inscription mardi 2 octobre 2001 Statut Membre Dernière intervention 8 juillet 2006 1
30 juil. 2003 à 16:00
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 
#include 
#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
0
cs_vieuxLion Messages postés 455 Date d'inscription samedi 26 octobre 2002 Statut Membre Dernière intervention 6 avril 2004 8
30 juil. 2003 à 18:22
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+
0
Rejoignez-nous