c++ - Dynamically allocating array of a custom class and overloading operators -


the last couple of days i've been trying figure out how make dynamically allocated array of class made. 1 of them includes class made

here classes:

template<typename t> class bst // binary search tree class { private:     node<t> * root;     int size; public:     bst()     {         root = null;         size = 0;     }  /*void * bst::operator new[](size_t a) //tried both "bst::" , without     {         void * p = malloc(a);//24         return p;     }*/ //there more functions cut out } 

and

template <typename t> class node //a node binary search tree { public:     int key;     t data;     node * left;     node * right;     node * parent; //public:     node<t>()     {         key = null;         data = null;         left = null;         right = null;         parent = null;     } //more stuff below it's getting , setting data } 

in main() i'll try make array of bst objects line:

bst<char> * t = new bst<char>[ n ]; //the user give value int n 

the issue makes 1 bst object when running. i've done research , experimented overloading new[] operator did absolutely nothing.

can please explain proper way be?

you have more 1 object in array, t not array.

t pointer one bst, , debugger displays such – debugger has no idea it's pointer first element of array.

if want view array, need tell debugger that.
in "watch" window, , think syntax t,2 displaying first 2 elements.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -