-
C-style design model is using global functions
and structs to hold data:
//Node.h
struct Node {
int data;
Node* next;
};
void insert_front(
struct Node* node,
struct Node* newNode )
{
newNode->next = node->next;
node->next = newNode;
}
|
-
#include <cstddef>
#include "Node.h"
int main ( )
{
struct Node A;
struct Node B;
struct Node C;
A.data = 12;
B.data = 99;
C.data = 37;
insert_front( &A, &C );
insert_front( &A, &B );
C.next = NULL;
return 0;
}
|