#include <iostream>
#include <vector>
 
using namespace std;
 
struct vertex;
 
vector< vertex > t;
 
struct vertex {
    int nxt;
    vertex() {
        nxt = 0;
    }
    int getNext() {
        if( nxt == 0 ) {
        	cout << "t.size() = " << t.size() << endl;
            nxt = t.size();
            cout << "new nxt = " << nxt << endl;
            t.push_back( vertex() );
        }
        cout << "nxt = " << nxt << endl;
        return nxt;
    }
};
 
int main() {
    t.push_back( vertex() );
    cout << t[0].getNext() << endl;
    cout << t[0].getNext() << endl;
 
    return 0;
}