#include <iostream>
#include <stack>
using namespace std;
template <typename T>
class Node {
T data;
public:
Node<T>* left;
Node<T>* right;
Node(T data) {
this->data = data;
left = right = NULL;
}
T getData() {
return data;
}
};
//Inorder traversal using iterative
template<typename T>
void printInorder(Node<T>* root) {
stack<Node<T>*> s; // Getting linking error here************
Node<T>* cur = root;
s.push(cur);
while (cur != NULL && !s.empty()) {
while (cur != NULL) {
cur = cur->left;
if(cur != NULL) s.push(cur);
}
cur = s.top();
s.pop();
cout << cur->getData() << " ";
cur = cur->right;
}
}
int main() {
Node<int>* root = new Node<int>(1);
root->left = new Node<int>(2);
root->right = new Node<int>(3);
root->left->left = new Node<int>(4);
root->left->right = new Node<int>(5);
printInorder<int>(root);
cin.get();
return 0;
}
Ошибка:
> Severity Code Description Project File Line Suppression State
> Error LNK2019 unresolved external symbol __imp___invalid_parameter
> referenced in function "void * __cdecl
> std::_Allocate_manually_vector_aligned<struct
> std::_Default_allocate_traits>(unsigned int)"
> (??$_Allocate_manually_vector_aligned@U_Default_allocate_traits@std@@@std@@YAPAXI@Z) DataStructure C:\Users\rkaqrb\source\repos\DataStructure\Traversal(Tree).obj 1