Skip to main content
gamedev.net
🔒 Locked

[C++] Functions with flags

Started by Auraomega Mar 27, 2009 at 6:39 PM 2 replies 700+ views
Original Post
Auraomega
Auraomega
I want to make a function that accepts flags for a particle engine I'm working on, except I'm not sure how and my Google-fu sucks today so I've not found anything useful... there might not be any difference but heck, I'm not designing code until I know how for sure. I just want something like this: enum stretchParticle_ { STRETCH_X, STRETCH_Y, STRETCH_Z }; void stretchParticle(flagType flag); and then pass something like stretchParticle(STRETCH_X | STRETCH_Y); -Aura
Kimmi
Kimmi
Do you mean something like:
enum foo{  bar1 = 0x001 // first bit  bar2 = 0x002 // second bit  bar3 = 0x004 // third bit};test( bar1 |bar2|bar3 );


So you just can set the several bits by using the |-operator.

Kimmi
A complicate solution may indicate a not understood problem.


[twitter]KimKulling[/twitter]
Auraomega
Auraomega
Yeah thats basically the idea, and I know how to pass them I'm just confused what to do on the other end ;)

-Aura
SiCrane
SiCrane
if (flag & STRETCH_X) {  // stuff for STRETCH_X}if (flag & STRETCH_Y) {  // stuff for STRETCH_Y}// etc.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.