bitfields as static members?

G

Guest

Hello,

I'm attempting to define a class that has a bitfield as a static
member. The definition seems ok, but I'm at a loss as to how to declare
it:

class Test {
static struct TestBitFields {
unsigned int Flag1:1;
unsigned int Flag2:1;
} BitFields;
};

Thanks in advance!
 
G

Guest

Hello,

I'm attempting to define a class that has a bitfield as a static
member. The definition seems ok, but I'm at a loss as to how to declare
it:

class Test {
static struct TestBitFields {
unsigned int Flag1:1;
unsigned int Flag2:1;
} BitFields;
};

Thanks in advance!

Er, please ignore the ommission of "public". :)
 
V

Victor Bazarov

I'm attempting to define a class that has a bitfield as a static
member. The definition seems ok, but I'm at a loss as to how to
declare it:

class Test {
static struct TestBitFields {
unsigned int Flag1:1;
unsigned int Flag2:1;
} BitFields;
};

I think you got those things in reverse. You already declared the
struct and the member. Now you need to define it:

class Test {
...
};

Test::TestBitFields Test::BitFields;

V
 
G

Guest

Victor said:
I think you got those things in reverse. You already declared the
struct and the member. Now you need to define it:

Duh, you're right. Thanks for pointing out my oversight!
class Test {
...
};

Test::TestBitFields Test::BitFields;

Works like a charm; thanks. Even got initialization going. :)
 

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

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top