memberA is defined in the header of ClassA.
memberB is defined in the header of ClassB.
ClassB is a subclass of ClassA
Inside an instance of ClassB, setting memberA via simple assignment:
memberA = 0.05
...also changes memberB, but to a crazy number -- 1028443341. Additionally, assigning 0.05 to memberA results in memberA showing up in the debugger as 5.33083531e-38.
Both variables are floats, neither is a pointer. I'm almost certianly making some noob mistake, but I don't have any clue what it might be. What sort of screw-up might make it so assigning a value to one variable results in crazy values appearing in two variables?
********************* Edit **********************
I narrowed the problem down to some "trickiness" I'd done in order to get C++ member variables:
Thanks for all the thoughts folks. It's dangerous letting a noob like me at this low-level language stuff! Here's where the problem was:
@interface LoopyPulser : NSObject{
float _pulseRate;
UInt32 tickInterval;
UInt32 step;
InMemoryAudioFile * audioFilePlayer;
#ifdef __cplusplus
ADSR* env;
StkFrames* audioFrames;
# endif
Pattern * pattern;
float loopLengthRatio;
float volume;
}
I read about this #ifdef __cplusplus business somewhere else on SO, as a way to have C++ imports in header files which are then imported by Obj-C files. Seems to me now that this is a terrible idea, and most likely the cause of my crazy bug. If I remove the member vars inside the #ifdef __cplusplus, the insanity goes away.
So what's the best way to have C++ member variables in Obj-C++? Can I use ids maybe?