Jak dodawać wartości do drzewa BST?

0

Witam, pisze właśnie drzewo binarne ale nie wiem jak dodawać do niego wartości:
plik główny:

#include "wezel.h"
#include <memory>
using namespace std;

int main()
{
	unique_ptr<wezel> bst = nullptr;
	cout << bst.get() << endl;
	addToTree(bst, 4);
}
 

plik nagłówkowy:

 #pragma once
#include <memory>
#include <iostream>
struct wezel
{
	std::unique_ptr<wezel> lewy;
	int wartosc;
	std::unique_ptr<wezel> prawy;
	//std::unique_ptr<wezel> rodzic;
	wezel(int wartosc) : wartosc(wartosc){};
};

std::ostream& operator <<(std::ostream& wyjcie, wezel*w);

void addToTree(std::unique_ptr<wezel>& bst, int value);

plik cpp do nagówkowego:

 #include "wezel.h"

std::ostream & operator<<(std::ostream & wyjscie,const std::unique_ptr<wezel> &w)
{
	// TODO: insert return statement here
	wyjscie << w->lewy.get() << w->wartosc << w->prawy.get();
	return wyjscie;
}

void addToTree(std::unique_ptr<wezel>& bst, int value)
{
		if (bst) {
			if (bst->wartosc > value) {
				addToTree(bst->lewy, value);
			}
			else if (bst->wartosc < value) {
				addToTree(bst->prawy, value);
			}
		}
		else {
			bst = std::make_unique<wezel>(value);
		}
}

program się nie kompiluje, kompilator podaje błędy:

1.Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2019	unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct wezel *)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@PAUwezel@@@Z) referenced in function _main	BST	C:\Users\Piotr\Desktop\Drzewo BST\BST\BST\main.obj	1	
2.Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK2001	unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct wezel *)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@PAUwezel@@@Z)	BST	C:\Users\Piotr\Desktop\Drzewo BST\BST\BST\wezel.obj	1	
3.Severity	Code	Description	Project	File	Line	Suppression State
Error	LNK1120	1 unresolved externals	BST	C:\Users\Piotr\Desktop\Drzewo BST\BST\Debug\BST.exe	1	

Nie mam pojęcia co je powoduje, ale podejrzewam że dodawanie do drzewa jest źle zrobione, a nie wiem jak to inaczej rozwiazać, chętnie zobaczę jakieś zgrane rozwiązanie tego problemu.

1

Deklaracja tej funkcji różni się od definicji u ciebie

 std::ostream& operator <<(std::ostream& wyjcie, wezel*w);

std::ostream & operator<<(std::ostream & wyjscie,const std::unique_ptr<wezel> &w)
{
    // TODO: insert return statement here
    wyjscie << w->lewy.get() << w->wartosc << w->prawy.get();
    return wyjscie;
}

1 użytkowników online, w tym zalogowanych: 0, gości: 1