3

Possible Duplicate:
What does 'unsigned temp:3' mean?

I saw some c++ code today that used single colons.

bool variable_name : 1;

what is the difference between this and

bool variable_name = true;
Community
  • 1
  • 1
William Jia
  • 1,057
  • 2
  • 9
  • 12

1 Answers1

3

The ": 1" means it is a bit field with 1 bit, or at least that's what it means in C. It probably was put there to save some memory, allowing multiple bools to be stored in the same byte. The downside is that you probably can't make a pointer to that bool.

David Grayson
  • 84,103
  • 24
  • 152
  • 189