fork download
  1. template<typename T>
  2. class LinkedList {
  3. private:
  4. struct Node; // Private forward declaration of the private class
  5.  
  6. public:
  7. class LinkedListIterator {
  8. public:
  9. LinkedListIterator(Node* node) : node(node) {}
  10. LinkedListIterator& operator++() {
  11. if (node != nullptr) {
  12. node = node->next;
  13. }
  14. }
  15. private:
  16. Node* node;
  17. };
  18. LinkedListIterator begin() {
  19. return LinkedListIterator(head);
  20. }
  21. private:
  22. struct Node {
  23. Node* next;
  24. };
  25. Node* head;
  26. };
  27.  
  28. int main()
  29. {
  30. return 0;
  31. }
Success #stdin #stdout 0s 3408KB
stdin
Standard input is empty
stdout
Standard output is empty