// Node for singly linked list // // #ifndef NODE_H_ // #define NODE_H_ class Node { friend class LL; // so LL can access the private data private: long data; Node *next; public: Node( long d = 0, Node *n = nullptr) { data = d; next = n; } }; // #endif // NODE_H_ // singly linked list // // #ifndef LL_H_ // #define LL_H_ // #include "Node.h" class LL { private: Node *head, *tail; public: LL() { head = tail = nullptr; } bool empty() const; // true if list is empty, otherwise false void push_front( long d); // insert in front of head void push_back( long d); // insert after tail long pop_front(); // remove from head long pop_back(); // remove from tail void reverse(); // put list in reverse order void print() const; // print the list }; // #endif // LL_H_ // singly linked list // #include // #include "LL.h" using namespace std; void LL::push_front( long d) { } void LL::push_back( long d) { } void LL::print() const { } #include // #include "LL.h" using namespace std; int main() { LL list; // testing... // long a[] = { 1, 2, 3, -1 }; for( int i = 0; a[i] > 0; ++i) list.push_front(a[i]); list.print(); }