In the context of C++ (not that it matters):
class Foo{
private:
int x[100];
public:
Foo();
}
What I've learnt tells me that if you create an instance of Foo like so:
Foo bar = new Foo();
Then the array x is allocated on the heap, but if you created an instance of Foo like so:
Foo bar;
Then it's created on the stack.
I can't find resources online to confirm this.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…