Amazon Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: Phone Interview
First one is just an object of MyObject named foo.
Second one is a pointer to the object of MyObject.
Third one creates an object of MyObject and points the variable to that object.
1) MyObject foo;
- techcoder November 24, 2011foo object of type is created on stack (memory of size sizeof(MyObject) is allocated on stack.
2) MyObject *bar;
pointer of type MyObject class is created which is pointing to some unknown location.
3) MyObject *foobar = new MyObject();
memory is allocated on heap.