Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Example Node Program
// Example program using Node #include <iostream> using namespace std; template<class ItemType> class Node { private: ItemType item; // A data item Node<ItemType>* next; // Pointer to next node public: Node() {next = nullptr;}; void setItem(const ItemType& anItem) {item = anItem;}; void setNext(Node<ItemType>* nextNodePtr) {next = nextNodePtr;}; ItemType getItem() const {return item;}; Node<ItemType>* getNext() const {return next;}; }; // end Node int main() { cout << "*** Example Node Program for ECE 2574 ***\n\n"; Node<int> intNode1; Node<int> intNode2; intNode1.setItem(1); intNode2.setItem(2); // add some code here for the in-class quiz int count = 0; while (headPtr != nullptr) { cout << " Node " << ++count << " value is: " << headPtr->getItem() << endl; headPtr = headPtr->getNext(); } cout << endl; }
run
|
edit
|
history
|
help
0
Crow unordered_map Quiz
range based for loop temporary object lifetime issue example
applidiumResto_NicolasCarre
10 naturalnumbers
bank queue
Move Construction
Result of not joining thread in main()
AnnotateAttr templated test
non-template template parameters for container stream insertion: SFINAE
A