Assume we create an object on stack as
class Test{
Test(int i) {i_=i;}
Test(std::vector<int> v) {v_=v;}
int i_;
std::vector<int> v_;
};
int main() {
Test a;
// how much memory is occupied/reserved now for a?
.
.
.
return 0;
}
How compiler determines the required size for "a", when it is not yet known which constructor is going to be called? I mean, how much memory is reserved on stack? what about if i used "new" for object creation?
My example is very simplified in order to transfer my point. The aim of my question is to understand better the meaning of object creation/initialization on stack/heap.