Advertisement Jump to content
Sign in to follow this  
roby65

[C++] Creating bitstream class

This topic is 3844 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi guys, reading some theoric tutorials i'm trying to create a bitstream class..... this is what i've done: class bitstream { char buffer[200]; int bit; public: bitstream() { bit=0; for(int i=0;i<sizeof(buffer);i++) buffer=0; } int bits(){return bit;} void AddBit(bool val); }; void bitstream::AddBit(bool val) { if(!val) { bit++; return; } unsigned char mask=128; int idx=(bit/8); mask=(mask>>(bit%8)); buffer[idx] |= mask; bit++; return; } now i want to do a "bitcopy" method....but can't understand how it should work....can anyone explain me?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by roby65

now i want to do a "bitcopy" method....but can't understand how it should work....can anyone explain me?


Probably not, unless you specify what bitcopy does, or at least what signature it has.

Right now, your class can store exactly one bit of information.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!