Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Node.h"
- #include <iostream>
- using namespace std;
- void PrintList(Node*pHead)
- {
- for (Node*pCurront = pHead; pCurront != nullptr;pCurront=pCurront->getpNext())
- {
- cout << pCurront->getData() << endl;
- }
- }
- void AddListHead(const DataType &data, Node*&pHead)
- {
- Node*pNew = new Node;
- pNew->setData(data);
- pNew->setpNext(pHead);
- pHead = pNew;
- }
- int main()
- {
- Node n;
- int a = 3;
- n.setData(a);
- //cout << n.getData()<<endl;
- Node*pHead = new Node(1);
- pHead->setpNext(new Node(3));
- PrintList(pHead);
- AddListHead(0, pHead);
- PrintList(pHead);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement