Colon in C++ private member declarations?

R

Rick Pingry

I have been looking over the DSO Framer example
(http://support.microsoft.com/kb/311765). As I reviewed the code, I saw
syntax that I have never come across in C++. In the header file, you see
some unsigned int private member variables with a colon and a value. It
looks like some kind of member initialization, but I did not know you could
do it that way in C++. Note that it is NOT a member initialization list as a
part of a constructor; I know what that is. Here is what it looks like:

class CDsoFramerClassFactory : public IClassFactory
{
....
private:
....
unsigned int m_fModeFlagValid:1; // has mode changed since
last check?
unsigned int m_fBorderStyle:2; // the border style
....
};

Any ideas?
 
J

Jeroen Mostert

Rick said:
I have been looking over the DSO Framer example
(http://support.microsoft.com/kb/311765). As I reviewed the code, I saw
syntax that I have never come across in C++. In the header file, you see
some unsigned int private member variables with a colon and a value. It
looks like some kind of member initialization, but I did not know you could
do it that way in C++. Note that it is NOT a member initialization list as a
part of a constructor; I know what that is. Here is what it looks like:

class CDsoFramerClassFactory : public IClassFactory
{
...
private:
...
unsigned int m_fModeFlagValid:1; // has mode changed since
last check?
unsigned int m_fBorderStyle:2; // the border style
...
};

Any ideas?

These are bitfields, and they're as old as C.

http://msdn.microsoft.com/library/ewwyfdbe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top