There is nothing wrong with this implementationMay be it's your compiler, here is the full running codeMine gives no error or warnings.
#include <iostream>
#include <vector>
using namespace std;
struct foo {
int x;
vector < foo > bar;
};
int main()
{
foo a;
foo b;
b.x = 3;
a.bar.push_back(b);
cout<<a.bar[0].x;
cout<<"\n";
return 0;
}
