#include <vector>
class A {
private:
std::vector<int> v_;
public:
A(int size = 100, int init_val = 100){
for(int i=0; i<size; i++)
v_.push_back(init_val);
}
};
In the main, if I do:
A a(1000, 100);
What really happens? It is the first time I’ve seen hardcoded parameters in a constructor!
The passed values will simply replace default values of parameters with the passed ones.
A a;will result in call toA::A(100, 100)A a(5);will result in call toA::A(5, 100)A a(5, 6);will result in call toA::A(5, 6)