Colon in C++ private member declarations?

  • Thread starter Thread starter Rick Pingry
  • Start date Start date
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?
 
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
 
Back
Top