The only thing that I said is that the code works. I stand by that, because I tested it before posting it.
Also, I got "123" on my screen when I ran wonginator1221's code. If it works, it works.
@Groove: In C++, the only difference between struct and class is the default public/private. (Schildt, H. (2003), 'C++: The Complete Reference, Forth Edition', "Structures and Classes Are Related", page 293, McGraw Hill/Osborne, California)
And for the love of god, please try it before posting anything about it.
struct myClass {
int i;
public:
void init(int I) {
i = I;
}
int show() {
return i;
}
};
void setup() {
myClass *p[16];
Serial.begin(9600);
for(uint16_t i = 0; i <= 5; i++) {
p[i] = (myClass *) malloc(sizeof(myClass));
}
p[0]->init(0);
p[2]->init(8);
p[6]->init(7);
Serial.println(p[0]->show());
Serial.println(p[2]->show());
Serial.println(p[6]->show());
}
void loop() {
}
[\code]
When I tried it, I got:
0
8
7
... on the serial monitor.
[quote]Your testing is far from complete.[/quote]
No. I just made a quick program to help someone that worked. If you want to explore the matter further, you are more than welcome to.