Fix infinite recursion in PrintList. (#642)

Also make `Stack`'s single-argument constructor explicit, which would have helped catch this at compile time.
This commit is contained in:
Geoff Romer
2021-07-13 09:57:22 -07:00
committed by GitHub
parent 6fa42a7f3c
commit 69b4b0086f
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ struct Stack {
Stack() { head = nullptr; }
// Creates an instance containing just `x`.
Stack(T x) : Stack() { Push(x); }
explicit Stack(T x) : Stack() { Push(x); }
// Pushes `x` onto the top of the stack.
void Push(T x) { head = new ListNode<T>(x, head); }