Public Group

# a few random questions

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

## Recommended Posts

I see that address locations are always in the form 0xnumbers. is the 0x prefix simply reserved for addresses or does it encompass more than just addresses? can it ever be 1x or 2x? if not, why the 0 in front? Also, I know you can type using namespace [name] but is there a way you can stop using the namespace.

##### Share on other sites
Addresses are (usually) 32 bit numbers, just like ints usually are.

To make addresses appear differently than numbers they print them in a hex format, where 0x means the value following is in hex. Ig you are using c++ and want to make an integer have the value of a number in hex, you can use the same prefix:

Stop using the namespace? If you mean stop typing the namespace's name you can do this:
namespace mynamespace{class SomeClass{};}// The class SomeClass is available without //specifing the mynamespace:: prefixusing mynamespace::SomeClass;int main(){   SomeClass someInstace;}// or// all symbols in mynamespace are available without //specifing the mynamespace:: prefixusing namespace mynamespace; int main(){   SomeClass someInstace;}

##### Share on other sites
okay so it's for hex representation. So if I wanted to I could do something like this?

int hex = 0xAAFF5522;

And there will be no problem. Which would be incrediably helpful with colors.

yeah, an inverse to using namespace.

example:

int main()
{
using mynamespace std;
cout << "hi";
//then turn it off
cout << "hello"; //error //no longer using namespace std, need fully qualifying name.
}

Is this possible?

##### Share on other sites
Quote:
 Original post by ELFanaticyeah, an inverse to using namespace.example:int main(){ using mynamespace std; cout << "hi"; //then turn it off cout << "hello"; //error //no longer using namespace std, need fully qualifying name.}Is this possible?

Removing an introduced namespace is not possible as far as I know. They are, however, limited by scope.
int main(){   {      using mynamespace std;      cout << "hi";   }      //then turn it off   cout << "hello"; //error //no longer using namespace std, need fully  qualifying name.}

Last line is an error now, for the reason stated in the comment.

##### Share on other sites
oh sweet, I think I understanding the difference between your two examples, that's pretty cool. I didn't know you could do it down to the class, I thought it'd have to resolve to a namespace. so I could do using namespace std::cout and only cout wouldn't need the prefix other STL classes would. That's good to know.

##### Share on other sites
Quote:
Original post by Brother Bob
Quote:
 Original post by ELFanaticyeah, an inverse to using namespace.example:int main(){ using mynamespace std; cout << "hi"; //then turn it off cout << "hello"; //error //no longer using namespace std, need fully qualifying name.}Is this possible?

Removing an introduced namespace is not possible as far as I know. They are, however, limited by scope.
int main(){   {      using mynamespace std;      cout << "hi";   }      //then turn it off   cout << "hello"; //error //no longer using namespace std, need fully  qualifying name.}

Last line is an error now, for the reason stated in the comment.

##### Share on other sites
For completeness:
Quote:
 Original post by ELFanaticokay so it's for hex representation. So if I wanted to I could do something like this?int hex = 0xAAFF5522;

You surely can. Once a literal integer gets through the compilation phase, it will be stored in binary, no matter how you specified it. It's just that sometimes it's more convenient to work in hexadecimal; others in decimal.

The following lines of code are not just functionally equivalent but will compile to precisely the same thing:
int x = 16;int x = 0x10;
Regards

• 10
• 48
• 12
• 10
• 10
• ### Forum Statistics

• Total Topics
631383
• Total Posts
2999680
×