Created
December 30, 2013 19:37
-
-
Save YuukiARIA/8186944 to your computer and use it in GitHub Desktop.
list link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct Node { | |
int m_value; | |
Node *m_prev; | |
Node *m_next; | |
}; | |
void link(Node *lhs, Node *rhs) | |
{ | |
lhs->m_next = rhs; | |
rhs->m_prev = lhs; | |
} | |
int main() | |
{ | |
Node *node1 = new Node; | |
Node *node2 = new Node; | |
node1->m_value = 123; | |
node2->m_value = 456; | |
cout << "それぞれの値" << endl; | |
cout << "node1の値 = " << node1->m_value << endl; | |
cout << "node2の値 = " << node2->m_value << endl; | |
// リンク | |
link(node1, node2); | |
cout << "node1の次の要素の値" << endl; | |
cout << node1->m_next->m_value << endl; | |
cout << "node2の前の要素の値" << endl; | |
cout << node2->m_prev->m_value << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment