diff --git a/librerie/exercise3/binarytree/binarytree.hpp b/librerie/exercise3/binarytree/binarytree.hpp index df22063..d1be6ad 100755 --- a/librerie/exercise3/binarytree/binarytree.hpp +++ b/librerie/exercise3/binarytree/binarytree.hpp @@ -30,14 +30,12 @@ public: protected: Data data; - // Comparison operators bool operator==(const Node&) const noexcept; // Comparison of abstract types is possible, but should not be visible. bool operator!=(const Node&) const noexcept; // Comparison of abstract types is possible, but should not be visible. bool EqualNodes(const Node&, const Node&) const; - public: friend class BinaryTree; diff --git a/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp b/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp index c427a70..ce823cc 100755 --- a/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp +++ b/librerie/exercise3/binarytree/lnk/binarytreelnk.cpp @@ -151,7 +151,7 @@ bool BinaryTreeLnk::operator!=(const BinaryTreeLnk& tree) const noex } template -struct BinaryTree::Node& BinaryTreeLnk::Root() const{ +struct BinaryTreeLnk::NodeLnk& BinaryTreeLnk::Root() const{ if(size==0) throw std::length_error("Empty tree!"); return *root; } diff --git a/librerie/exercise3/binarytree/lnk/binarytreelnk.hpp b/librerie/exercise3/binarytree/lnk/binarytreelnk.hpp index 76ed992..b299fb8 100755 --- a/librerie/exercise3/binarytree/lnk/binarytreelnk.hpp +++ b/librerie/exercise3/binarytree/lnk/binarytreelnk.hpp @@ -10,13 +10,13 @@ class BinaryTreeLnk : virtual public BinaryTree{ // Must extend BinaryTree protected: - struct NodeLnk : virtual protected BinaryTree::Node { // Must extend Node + struct NodeLnk : virtual public BinaryTree::Node { // Must extend Node protected: using BinaryTree::Node::data; - struct NodeLnk* left; - struct NodeLnk* right; + struct NodeLnk* left = nullptr; + struct NodeLnk* right = nullptr; public: struct NodeLnk& operator=(const NodeLnk&); // Copy assignment of abstract types should not be possible. @@ -56,14 +56,14 @@ public: // Specific member functions (inherited from BinaryTree) - struct BinaryTree::Node& Root() const override; // Override BinaryTree member (throw std::length_error when empty) + NodeLnk& Root() const override; // Override BinaryTree member (throw std::length_error when empty) // Specific member functions (inherited from Container) void Clear() override; // Override Container member // Specific functions - + struct BinaryTreeLnk::NodeLnk* CreateTreeFromLinearContainerInBreadth(const LinearContainer&,ulong); struct BinaryTreeLnk::NodeLnk* CopyTree(struct BinaryTreeLnk::Node*); void DeleteTree(BinaryTreeLnk::NodeLnk* node); diff --git a/librerie/exercise3/binarytree/vec/binarytreevec.cpp b/librerie/exercise3/binarytree/vec/binarytreevec.cpp index 3d456a2..89e0c35 100755 --- a/librerie/exercise3/binarytree/vec/binarytreevec.cpp +++ b/librerie/exercise3/binarytree/vec/binarytreevec.cpp @@ -141,7 +141,7 @@ bool BinaryTreeVec::operator!=(const BinaryTreeVec& bt) const noexcept{ } template -struct BinaryTree::Node& BinaryTreeVec::Root() const{ +struct BinaryTreeVec::NodeVec& BinaryTreeVec::Root() const{ if(size==0) throw std::length_error("Empty tree!"); return *(tree.Front()); } diff --git a/librerie/exercise3/binarytree/vec/binarytreevec.hpp b/librerie/exercise3/binarytree/vec/binarytreevec.hpp index 858e20c..9a334b2 100755 --- a/librerie/exercise3/binarytree/vec/binarytreevec.hpp +++ b/librerie/exercise3/binarytree/vec/binarytreevec.hpp @@ -12,7 +12,7 @@ class BinaryTreeVec : virtual public BinaryTree{ // Must extend BinaryTree protected: - struct NodeVec : virtual protected BinaryTree::Node { // Must extend Node + struct NodeVec : virtual public BinaryTree::Node { // Must extend Node protected: using BinaryTree::Node::data; @@ -33,7 +33,7 @@ protected: }; protected: - + using BinaryTree::size; Vector::NodeVec*> tree; @@ -54,7 +54,7 @@ public: // Specific member functions (inherited from BinaryTree) - struct BinaryTree::Node& Root() const override; // Override BinaryTree member (throw std::length_error when empty) + NodeVec& Root() const override; // Override BinaryTree member (throw std::length_error when empty) // Specific member functions (inherited from Container) diff --git a/librerie/exercise3/zmytest/test.hpp b/librerie/exercise3/zmytest/test.hpp index bbe113e..b2b22b1 100755 --- a/librerie/exercise3/zmytest/test.hpp +++ b/librerie/exercise3/zmytest/test.hpp @@ -36,8 +36,8 @@ void menu(){ BinaryTreeLnk bt1(vec); BinaryTreeLnk bt2(vec); -// if(bt1 == bt2) cout<<"uguali"; - + if(bt1 == bt2) cout<<"uguali"; + else cout<<"NON UGUALI!"; }