I saw a class defined using the syntax below, can somebody explain the syntax which is bolded?
class myClass{
private:
bool var : 1;
public:
myClass();
//etc...
}
http://www.cplusplus.com/forum/beginner/4268/
this might help
Doesn't really help. I mean forget the type. Say it was int var : 1?
So when you do something like:
1 2 3
|
int var:1
//or
bool var2:1
|
You have it allow the variable access to a number of bits
In your case it is 1, because in reality true and false only needs one bit, 1 or 0. Get it?
Last edited on
A bit. But IIRC you can only do it in classes.
Woops edited before I saw your post, had to go grab a book.
Ah, yes that is the syntax for bit fields. Thanks.