activity needs to be a pointer. Only pointers can allocate memory dynamically. Also, why would you allocate each element dynamically? The STL vector does that for you.
STL vectors take care of their own memory, thus removing the need for Static vs Dynamic declaration. You can remove all "new" stuff; you'll never need it in combination with vectors. If you replace all the "new int" stuff with a value, it should work.
To "reserve spots", use .resize(). Or, if possible, use the constructor to automatically assign spaces:
1 2
vector<int> myInts(30, 0); // Initializes a vector with 30 ints set to 0.
vector<activity> myActivities(30); // Initializes a vector of 30 "empty" activities.
One exception is your resource_requirements variable. A "basic" initalization of a vector leaves it with size 0. This can easily be taken care of:
activity[i].resource_requirements.resize(30); // Will assign 30 (uninitialized!) int spots.
If you find that not every activity has an equal (or pre-determined) amount of resource_requirements, you can always use the .push_back(T) command to add an additional T spot (e.g. activity[i].resource_requirement[j].push_back(5) will add a 31st integer "5").
So I don't need to use new operator with vectors. Actually I used them to speed up the program when I try to reach every element of vectors. How about the using pointers to speed up during reaching ? Does it matter in terms of speed ?
I'm sorry, I don't really know what you mean. I don't see how initializing pointers would ever speed up anything. Behind the scene, vectors are purely pointers anyway.
As far as I know, pointers only make a difference in performance when passing arguments to functions, where pointers/references eliminate the creation of copies behind the scenes.