Re: Bits in integer-Wert

David Haller <[email protected]>
Newsgroups gmane.linux.suse.programming
Message-ID <[email protected]>
Hallo,

Am Tue, 05 Apr 2005, Tobias Erbsland schrieb:
>> #include <bitset>
>> #include <iostream>
>>
>> using namespace std;
>
>Wo unterrichtet man denn dieses "using namespace std;" ?

Keine Ahnung. Bei mir ist es schlichte Tippfaulheit. Das mach ich aber
auch nur mit std [1].

[..]
>Das ist eher ein C++ Ansatz, jedoch deutet die for Schleife und viel

s.u.

>schlimmer das #define noch auf den eingefleischten C Programmierer
>hin.

"#define" kann auch mit C++ sehr sinnvoll sein ;)

>int main( int argc, char* argv[] )
>{
>  const int x = 42;
>
>  std::bitset<sizeof(x)*8> x_bits( x );
>  std::cout << "Number of bits set: " << x_bits.count() << std::endl;
                                                ^^^^^^^^ das hatte
ich auf die Schnelle nicht gesehen. Ich wollte auch nur auf <bitset>
hinweisen. Danke fuer die Ergaenzung.

-dnh

[1] wobei das mit meinem alten g++ / libstdc++ eh "Pflicht" ist, denn
    auch ohne das 'using namespace std;' ist std "importiert"...

-- 
"We must do something.  This is something.  Therefore we must do this."
        -- Military and Corporate Logic

-- 
Um die Liste abzubestellen, schicken Sie eine Mail an:
    [email protected]
Um eine Liste aller verfÃŒgbaren Kommandos zu bekommen, schicken
Sie eine Mail an: [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.