Timeline for How to loop over objects or pass object to function?
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 5, 2016 at 17:33 | comment | added | Phil | @Majenko thanks for your answer. It has been a great deal of help. I was wondering, however, instead of having an array of pointers with references to class objects, couldn't we just have an array of these objects and reference them like myObj &obj = arr[idx];? | |
| Sep 21, 2015 at 13:46 | vote | accept | jbyrnes | ||
| Sep 21, 2015 at 9:11 | comment | added | Majenko | If your constructor takes parameters then you add parameters. If it doesn't you don't. It is a little confusing and I have no idea why they did it that way. | |
| Sep 21, 2015 at 9:10 | comment | added | Majenko |
No, it's just an array [] of pointers *. If it was a pointer to an array of pointers it would be SomeClass **things[2] - exactly the same as in C.
|
|
| Sep 21, 2015 at 6:05 | comment | added | jbyrnes | From my C experience, this looks like a pointer to an array of pointers: SomeClass *things[2] = {&classA, &classB}; Is it different in C++? | |
| Sep 21, 2015 at 6:03 | comment | added | jbyrnes | Thanks for your answer! I should have included a more complicated constructor, the actual objects are created as eg: AccelStepper stepperA(AccelStepper::HALF4WIRE, motorPinA1, motorPinA3, motorPinA2, motorPinA4); Does this still hold with the above? | |
| Sep 20, 2015 at 16:00 | history | answered | Majenko | CC BY-SA 3.0 |