online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include "List.hpp" #include "ListNode.hpp" int main() { List<int> myList; myList.insert_head(); myList.insert_head(); myList.insert_head(); myList.print_list(); myList.remove_head(); myList.print_list(); return 0; }
#pragma once #include <iostream> template <class T> class ListNode; template <class T> class List { private: int size; ListNode<T> *head; public: List() : size(0), head(nullptr) { } ~List() { std::cout << "Destructor:" << std::endl; while (size > 0) { remove_head(); } std::cout << "Successfully deleted Linked List"; } void insert_head() { ListNode<T> *aNewNode = new ListNode<T>; aNewNode->next = head; head = aNewNode; size++; } void remove_head() { int what_item = head->item; if (size > 0) { ListNode<T> *temp = head; head = head->next; delete temp; size--; } std::cout << "Removed node containing: " << what_item << std::endl; } void print_list() { std::cout << std::endl; ListNode<T> *ptr = head; std::cout << "The items in the list are:" << std::endl; while (ptr != NULL) { std::cout << ptr->item << std::endl; ptr = ptr->next; } std::cout << std::endl; } };
#pragma once template <class T> class ListNode { private: int item; ListNode<T> *next; public: friend class List<T>; ListNode() { std::cout << "Input Integer: "; std::cin >> item; next = nullptr; } ~ListNode() { /* Add your implementation */ } };

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue