mirror of https://github.com/xfarrow/lasd.git
parent
8e56f33808
commit
5e58c3e7f4
|
@ -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<Data>;
|
||||
|
|
|
@ -151,7 +151,7 @@ bool BinaryTreeLnk<Data>::operator!=(const BinaryTreeLnk<Data>& tree) const noex
|
|||
}
|
||||
|
||||
template <typename Data>
|
||||
struct BinaryTree<Data>::Node& BinaryTreeLnk<Data>::Root() const{
|
||||
struct BinaryTreeLnk<Data>::NodeLnk& BinaryTreeLnk<Data>::Root() const{
|
||||
if(size==0) throw std::length_error("Empty tree!");
|
||||
return *root;
|
||||
}
|
||||
|
|
|
@ -10,13 +10,13 @@ class BinaryTreeLnk : virtual public BinaryTree<Data>{ // Must extend BinaryTree
|
|||
|
||||
protected:
|
||||
|
||||
struct NodeLnk : virtual protected BinaryTree<Data>::Node { // Must extend Node
|
||||
struct NodeLnk : virtual public BinaryTree<Data>::Node { // Must extend Node
|
||||
|
||||
protected:
|
||||
|
||||
using BinaryTree<Data>::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,7 +56,7 @@ public:
|
|||
|
||||
// Specific member functions (inherited from BinaryTree)
|
||||
|
||||
struct BinaryTree<Data>::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)
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ bool BinaryTreeVec<Data>::operator!=(const BinaryTreeVec& bt) const noexcept{
|
|||
}
|
||||
|
||||
template <typename Data>
|
||||
struct BinaryTree<Data>::Node& BinaryTreeVec<Data>::Root() const{
|
||||
struct BinaryTreeVec<Data>::NodeVec& BinaryTreeVec<Data>::Root() const{
|
||||
if(size==0) throw std::length_error("Empty tree!");
|
||||
return *(tree.Front());
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ class BinaryTreeVec : virtual public BinaryTree<Data>{ // Must extend BinaryTree
|
|||
|
||||
protected:
|
||||
|
||||
struct NodeVec : virtual protected BinaryTree<Data>::Node { // Must extend Node
|
||||
struct NodeVec : virtual public BinaryTree<Data>::Node { // Must extend Node
|
||||
|
||||
protected:
|
||||
using BinaryTree<Data>::Node::data;
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
|
||||
// Specific member functions (inherited from BinaryTree)
|
||||
|
||||
struct BinaryTree<Data>::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)
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ void menu(){
|
|||
|
||||
BinaryTreeLnk<string> bt1(vec);
|
||||
BinaryTreeLnk<string> bt2(vec);
|
||||
// if(bt1 == bt2) cout<<"uguali";
|
||||
|
||||
if(bt1 == bt2) cout<<"uguali";
|
||||
else cout<<"NON UGUALI!";
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue