Allocation Detail

I need to declare and initialize a vector as a field of a class named PixelOperator. There are 2 ways to declare it:

1. vector<int>* field = new vector<int>(); //on the heap
2. vector<int> field = vector<int>(); //on the stack

If I choose to declare in style number 1, I need to call delete in the destructor of the class.

If the class is initialized on the heap (ie. PixelOperator* op = new PixelOperator();), are fields initialized on the stack initialized on the heap?
I need to call delete in the destructor of the class
not if you use smart pointers http://www.umich.edu/~eecs381/handouts/C++11_smart_ptrs.pdf
If the class is initialized on the heap
not class, but class objects
are fields initialized on the stack initialized or the heap?
object is created on the heap and hence it's data members/fields are also on the heap
Topic archived. No new replies allowed.