By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

implementation suggestions

P: n/a
Referencing source below, depending on the value of a bitset object,
for the range 0..3, I call a function interrupt0, for the range 4..7 I
call a function interrupt1. I'd prefer to just call an 'interrupt'
function within the for loop. Within the interrupt function I'll then
call the appropriate interrupt0 and/or interrupt1 function. One idea
surrounds using a min/max range and perhaps a pointer to the
appropriate function. For instance.
For the range 0..3; I'll call function interrupt0, Similarily, for
the range 4..7, I'll call function interrupt1.

Suggestions on how I could achieve this and/or an alternate approach
would be appreciated. Thanks in advance
# include <bitset>

void interrupt0 ( int val ) {
printf ( "o" );
}
void interrupt1 ( int val ) {
printf ("x" );
}

int main() {

std::bitset < 8 bmask_obj ( 0xFF );
for ( std::size_t odx ( 0 ) ; odx < bmask_obj.size(); ++odx ) {
if ( bmask_obj [ odx ] ) {
if ( odx < 4 ) {
interrupt0 ( odx ) ;
} else if ( odx >= 4 && odx < 8 ) {
interrupt1 ( odx );
}
}
}

}

Jun 7 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.