holmes4:
- the data for that instance of the class eg servo1, servo2 which are created on the heap
This is true ONLY if you use new or malloc().
Here:
http://www.learncpp.com/cpp-tutorial/79-the-stack-and-the-heap/
learncpp:
In C++, when you use the new operator to allocate memory, this memory is assigned from the heap.
I can't find anything saying that objects go on the stack when they're allocated normally because it's such a silly question.
class myclass {
public:
int i;
};
myclass myobject; // on STACK
void setup() {
myclass myotherobject; // on STACK
} // myotherobject is destroyed
void loop() {
myclass* myclassptr; // pointer is on STACK
myclassptr = new myclass; // object is on HEAP --- must be destroyed
delete myclassptr; // object is no longer on heap
}
This link is also somewhat enlightening:
If you continue to insist that all class objects are created on the heap, you will need to provide references.
(sorry to afuite, this really isn't relevant to your question at all)