- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
#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;
}
3_dar 07.09.2016 22:58 # −12
kurwa 07.09.2016 23:16 # −12
kurwa 07.09.2016 23:23 # −11
> As long as you’re careful, it’s okay (not evil) for an object to commit suicide (delete this).
CTEPTOP 07.09.2016 23:43 # −30
guest0 08.09.2016 00:06 # −31
CTEPTOP 08.09.2016 00:13 # −30
bagridze 07.09.2016 23:20 # −9
1024-- 08.09.2016 08:14 # −10
Может, с порядком исполнения какая-то ерунда? Только где...
Soul_re@ver 08.09.2016 09:44 # −8
In particular, the effects are undefined in the following cases:
— if an incomplete type (3.9) is used as a template argument when instantiating a template component, unless specifically allowed for that component.