445,742 Members | 1,044 Online
Need help? Post your question and get tips & solutions from a community of 445,742 IT Pros & Developers. It's quick & easy.

# Setting value of a class

 P: n/a Consider the following platform: char = 8-bit short = 16-bit int = 32-bit long = 32-bit The largest value possible for unsigned long is 4,294,967,295 = 4.29 billion approx. Now imagine you're some sort of census people and you're keeping track of the population of the earth. You're going to want a 33-Bit Number. You look around and you find a library that has a certain class that gives you a 64- Bit number. The following is heavily contrived... but just bare with me. So here's how the system will work. #include class Human { protected: static SixtyFourBitInt amount_humans = 0; public: Human(void) { ++amount_humans; } ~Human(void) { --amount_humans; } }; static SixtyFourBitInt Human::amount_humans; This should all be fine and dandy... but how would one, or how does one (to those who have experience with this) actually manually set its value? Consider the following: SixtyFourBitInt numbr; numbr = 5000000000; This won't compile obviously. Do you have to do something like the following?: SixtFourBitInt numbr; numbr = 4000000000; numbr += 1000000000; How exactly would you do it? Another example, consider another class: class InternationalPhoneNumber; This class is going to (well..., wants to) use 4 bits for each digit, 0 through 9. Obviously, at some stage, the programmer will want to set the value of this beast. Would the following be the best course of action?: InternationalPhoneNumber disneylands_number = "44990561002"; And then just manipulate the string into 4 bits for each digit? Enlighten me! -JKop Jul 22 '05 #1