#include <iostream>
class Test
{
public:
Test(int _data, Test *_next = nullptr):data(_data), next(_next)
{}
int data;
Test *next;
};
int main()
{
Test test_node1(1);
Test test_node2(2);
Test test_node3(3);
test_node1.next = &test_node2;
test_node2.next = &test_node3;
for (Test *curr_node = &test_node1; curr_node != nullptr; curr_node = curr_node->next)
{
std::cout<<"Data: " <<curr_node->data<<std::endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKY2xhc3MgVGVzdAp7CglwdWJsaWM6CgkJVGVzdChpbnQgX2RhdGEsIFRlc3QgKl9uZXh0ID0gbnVsbHB0cik6ZGF0YShfZGF0YSksIG5leHQoX25leHQpCgkJe30KCQlpbnQgZGF0YTsKCQlUZXN0ICpuZXh0Owp9OwoKaW50IG1haW4oKSAKewoJVGVzdCB0ZXN0X25vZGUxKDEpOwoJVGVzdCB0ZXN0X25vZGUyKDIpOwoJVGVzdCB0ZXN0X25vZGUzKDMpOwoJCgl0ZXN0X25vZGUxLm5leHQgPSAmdGVzdF9ub2RlMjsKCXRlc3Rfbm9kZTIubmV4dCA9ICZ0ZXN0X25vZGUzOwoJCglmb3IgKFRlc3QgKmN1cnJfbm9kZSA9ICZ0ZXN0X25vZGUxOyBjdXJyX25vZGUgIT0gbnVsbHB0cjsgY3Vycl9ub2RlID0gY3Vycl9ub2RlLT5uZXh0KQoJewoJCXN0ZDo6Y291dDw8IkRhdGE6ICIJPDxjdXJyX25vZGUtPmRhdGE8PHN0ZDo6ZW5kbDsKCX0KCQoJcmV0dXJuIDA7Cn0=