Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
Dat pointers
7
Crow unordered_map Quiz
ECE2574_Function_Calling_Example
pointer to complete array does not convert implicitly to pointer to array of unknown bound
Argument passing by using reference and value
Vector examples....
Linker error while passing constexpr variable as const &
Tree Traversal and Node
HTML Timetable generator.cpp
Please log in to post a comment.