Click here to Skip to main content
15,898,134 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ MFC questions Pin
henry00115-Jun-04 5:18
henry00115-Jun-04 5:18 
GeneralRe: VC++ MFC questions Pin
toxcct15-Jun-04 5:33
toxcct15-Jun-04 5:33 
GeneralRe: VC++ MFC questions Pin
henry00115-Jun-04 5:43
henry00115-Jun-04 5:43 
GeneralRe: VC++ MFC questions Pin
toxcct15-Jun-04 5:47
toxcct15-Jun-04 5:47 
GeneralRe: VC++ MFC questions Pin
henry00115-Jun-04 5:51
henry00115-Jun-04 5:51 
GeneralRe: VC++ MFC questions Pin
toxcct15-Jun-04 5:52
toxcct15-Jun-04 5:52 
GeneralRe: VC++ MFC questions Pin
henry00115-Jun-04 5:56
henry00115-Jun-04 5:56 
QuestionHow to overload [] and = for bit assignment Pin
ICantChangeMyAcct14-Jun-04 15:48
ICantChangeMyAcct14-Jun-04 15:48 
I have the following class:

template<typename FLAGTYPE> // may be BYTE, WORD, ULONG...
class Flags {
public:
/**
The boolean indexing operator returns true if the indexed flag bit
is a one.
*/
bool operator[] (long ix) const
{
assert((long)ix >= 0 && (long)ix < 8*sizeof(FLAGTYPE));
return ((m_flags & (1<<ix)) != 0);
}

// ...

protected:
FLAGTYPE m_flags;
};

The bool operator[] makes it possible to write:

Flags<ULONG> f1 = 10;
bool b = f1[3]; // assigns bit 3 of f1, i.e. f1 & 0x08, to b

How do I define indexing and assignment operators that *set* bit 'ix' to a boolean value, so that I can write:

f1[3] = true;

AnswerRe: How to overload [] and = for bit assignment Pin
Michael Dunn14-Jun-04 20:28
sitebuilderMichael Dunn14-Jun-04 20:28 
QuestionCan I use Shell Extentions? Pin
ngocdq14-Jun-04 15:16
ngocdq14-Jun-04 15:16 
AnswerRe: Can I use Shell Extentions? Pin
Iain Clarke, Warrior Programmer14-Jun-04 23:44
Iain Clarke, Warrior Programmer14-Jun-04 23:44 
GeneralC++ question. Pin
WREY14-Jun-04 14:37
WREY14-Jun-04 14:37 
GeneralRe: C++ question. Pin
palbano14-Jun-04 15:18
palbano14-Jun-04 15:18 
GeneralRe: C++ question. Pin
WREY14-Jun-04 18:02
WREY14-Jun-04 18:02 
GeneralRe: C++ question. Pin
Indrawati14-Jun-04 16:37
Indrawati14-Jun-04 16:37 
GeneralRe: C++ question. Pin
WREY14-Jun-04 18:07
WREY14-Jun-04 18:07 
GeneralRe: C++ question. Pin
Indrawati14-Jun-04 18:46
Indrawati14-Jun-04 18:46 
GeneralRe: C++ question. Pin
WREY14-Jun-04 23:39
WREY14-Jun-04 23:39 
GeneralRe: C++ question. Pin
Michael Dunn14-Jun-04 20:31
sitebuilderMichael Dunn14-Jun-04 20:31 
GeneralRe: C++ question. Pin
WREY14-Jun-04 23:50
WREY14-Jun-04 23:50 
GeneralRe: C++ question. Pin
toxcct15-Jun-04 1:13
toxcct15-Jun-04 1:13 
GeneralRe: C++ question. Pin
WREY15-Jun-04 3:16
WREY15-Jun-04 3:16 
GeneralRe: C++ question. Pin
toxcct15-Jun-04 3:24
toxcct15-Jun-04 3:24 
GeneralRe: C++ question. Pin
toxcct14-Jun-04 22:15
toxcct14-Jun-04 22:15 
GeneralRe: C++ question. Pin
bikram singh15-Jun-04 6:50
bikram singh15-Jun-04 6:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.