Which means we can supply an initializer and the default ctor isn't only way to the element of class type.
I write this code compiled in GCC 6.30:
#include <vector>
#include <iostream>
using namespace std;
class A
{
private:
int a;
public:
A() = delete;
A(int i): a(i) {}
friend int get_a(const A& object_A) { return object_A.a; };
};
int main(int argc, char const *argv[])
{
vector<A> vA(1, {123});
for (auto & i : vA)
{
cout << get_a(i) << endl;
}
cout << "After resize:" << endl;
vvi.resize(11, {123});
for (auto & i : vA)
{
cout << get_a(i) << endl;
}
return 0;
}
And thx for you to sharing the answers. :)