/ Forside / Teknologi / Udvikling / C/C++ / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
C/C++
#NavnPoint
BertelBra.. 2425
pmbruun 695
Master_of.. 501
jdjespers.. 500
kyllekylle 500
Bech_bb 500
scootergr.. 300
gibson 300
molokyle 287
10  strarup 270
cout
Fra : Thomas Sejr Jensen


Dato : 09-01-01 17:20

Hej!

Kan det passe at følgende ikke kan compileres?

string s="tekst";
cout<<s;

Jeg får følgende fejl:
error C2679: binary '<<' : no operator defined which takes a right-hand
operand of type 'class std::basic_string<char,struct
std::char_traits<char>,class std::allocator<char> >' (or there is no
acceptable conversion

Hvis jeg skriver cout<<"etEllerAndet"; virker det fint.
Hvordan får man ellers en string-variabel udskrevet?
På forhånd tak!
-----------------------------------------
Thomas Sejr Jensen
Thomassj@worldonline.dk
-----------------------------------------



 
 
Igor V. Rafienko (09-01-2001)
Kommentar
Fra : Igor V. Rafienko


Dato : 09-01-01 17:40

* Thomas Sejr Jensen

[snip]

> Jeg får følgende fejl:
> error C2679: binary '<<' : no operator defined which takes a right-hand
> operand of type 'class std::basic_string<char,struct
> std::char_traits<char>,class std::allocator<char> >' (or there is no
> acceptable conversion


Kompilator?


> Hvis jeg skriver cout<<"etEllerAndet"; virker det fint.
> Hvordan får man ellers en string-variabel udskrevet?


std::cout << std::string( "foo" );

_skal_ fungere (dersom <iostream> og <string> er #include'ert)





ivr
--
Much of this software was user-friendly, meaning that it was intended
for users who did not know anything about computers, and furthermore
had absolutely no intention whatsoever of learning.
   -- A. S. Tanenbaum, "Modern Operating Systems, ch 1.2.4"

Thomas Sejr Jensen (09-01-2001)
Kommentar
Fra : Thomas Sejr Jensen


Dato : 09-01-01 19:06

Tak for hurtigt svar!
Efter jeg har included <string> virker det fint.
M.V.H. Thomas.
"Igor V. Rafienko" <igorr@ifi.uio.no> skrev i en meddelelse
news:xjv1yuc4r2d.fsf@skepnuskapur.ifi.uio.no...
> * Thomas Sejr Jensen
>
> [snip]
>
> > Jeg får følgende fejl:
> > error C2679: binary '<<' : no operator defined which takes a right-hand
> > operand of type 'class std::basic_string<char,struct
> > std::char_traits<char>,class std::allocator<char> >' (or there is no
> > acceptable conversion
>
>
> Kompilator?
>
>
> > Hvis jeg skriver cout<<"etEllerAndet"; virker det fint.
> > Hvordan får man ellers en string-variabel udskrevet?
>
>
> std::cout << std::string( "foo" );
>
> _skal_ fungere (dersom <iostream> og <string> er #include'ert)
>
>
>
>
>
> ivr
> --
> Much of this software was user-friendly, meaning that it was intended
> for users who did not know anything about computers, and furthermore
> had absolutely no intention whatsoever of learning.
> -- A. S. Tanenbaum, "Modern Operating Systems, ch 1.2.4"



Søg
Reklame
Statistik
Spørgsmål : 177501
Tips : 31968
Nyheder : 719565
Indlæg : 6408524
Brugere : 218887

Månedens bedste
Årets bedste
Sidste års bedste