0

I have a simple header file that stands for a templated BST implementation, and would like to create a type alias to a nested struct but to no avail...

Header

#pragma once

#include <memory>

using namespace std;

namespace NYNE {

    template <typename T>
    class BST {

    protected:

        struct Node {
            T data;
            shared_ptr<Node> previous;
            shared_ptr<Node> next;

            Node(const T& t);
            Node(const T& t, const shared_ptr<T>& previous, const shared_ptr<T>& next);

            Node& smaller() const;
            Node& bigger() const;
        };

        int m_num_elements;

        shared_ptr<Node> m_first;

    public:

        BST();

        bool insert(const T& element);
        bool remove(const T& element);
    };
}

Implementation

#include "BST.h"

using namespace NYNE;

template <typename T>
BST<T>::BST() {
    m_num_elements = 0;
    m_first = nullptr;
}

template <typename T>
using typename Node = BST<T>::Node;       // <- here

template <typename T>
BST<T>::Node::Node(const T& t) {
    data = t;
    smaller() = nullptr;
    bigger() = nullptr;
}

template <typename T>
BST<T>::Node::Node(const T& t, const shared_ptr<T>& previous, const shared_ptr<T>& next) {
    data = t;
    smaller() = previous;
    bigger() = next;
}

I don't understand if the problem is with the header file or the type alias declaration itself.

Compiler error below (it literally means nothing).

bst.cpp(12): error C2059: erreur de syntaxe : ''

Any help is appreciated.

Barry
  • 286,269
  • 29
  • 621
  • 977
PinkTurtle
  • 6,942
  • 3
  • 25
  • 44

0 Answers0