memberA is defined in the ClassA header.
memberB is defined in the ClassB header.
ClassB is a subclass of ClassA
Inside an instance of ClassB, setting element A through a simple assignment:
memberA = 0.05
... also modifies memberB, but to a crazy number - 1028443341. In addition, assigning 0.05 to member makes memberA appear in the debugger as 5.33083531e-38.
Both variables are a float, and not a pointer. I am almost surely making a mistake, but I do not know what it can be. What kind of hang can lead to the fact that assigning a value to one variable will lead to crazy values appearing in two variables?
********************** Edit ***********************
I narrowed down the problem to some "trick" I did to get C ++ member variables:
Thanks to all the people. This is dangerous, letting a noob like me in this low-level language! Here where the problem is:
@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 sharing somewhere else in SO, as a way to import C ++ into header files, which are then imported using Obj-C files. It seems to me that this is a terrible idea and, most likely, the reason for my crazy mistake. If I delete the membership rows inside #ifdef __cplusplus, the madness goes away.
So what is the best way to have C ++ member variables in Obj-C ++? Can I use identifiers, maybe?