|
| 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"
| |
|
|