My project continues... But at least I'm getting better at using C/C++ and MFC.
Now, I'm at a critical point: dynamic memory allocation fundamentals.
I have a data class with a number of unsigned char arrays and longs that are addressed in structs (encapsulated by the class).
I'd like to make a vector of this data class. I have no use for the '==' and '<' operators, but I'll overload them anyway, but my problem is this:
I've got long arrays of unsigned chars (1000+spaces), and I intend to have about 250 different instances of this class in memory during regular operation.
How do I make a constructor for those unsigned char arrays? Should I make a loop, or can I just initialize the first element of an array and call it good?
Additionally, the file where this is declared is #included by two files that I'm intentionally keeping apart for ease of coding.
I'm using the
#ifndef #def #endif
directives to isolate the class to one defintion, but for some reason...
If I put this class in there, only the class itself is protected by the preprocessor. If I put the class constructor outside the terminating bracket for the class, I get "already defined in suchandsuch.obj" errors.
And it's the same with the overloaded operator functions.
How can I fix these problems?
Placing the overloads inside the class seems to fix the redefinition problem, but they now claim that the binary operator < has too many parameters. Doesn't 'bi' translate to two? As in, the two parameters that I'm trying to explicitly overload?