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
set/map equal_range bug in libc++
pointer to pointer
001
std::function ambiguity clang
NaN inside set
C++ Standard Template Library
HTML Timetable generator.cpp
Rounding float to nearest 1000 (fixed)
2574 EC
You can't erase a std::unordered_map::local_iterator