destructors and pointers issue

i have a templated class btree, below is the internal representation of said class from the btree.h file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  struct Node {
    Node(size_t max, Node *previous) :
      elem_(max), previous_(previous), children_(max+1), amount_(0) {}
    ~Node() {
      for (typename std::vector<Node*>::iterator it = children_.begin();
           it != children_.end(); ++it)
      {
        ~(**it);
        delete (*it);
      }
      delete previous_;
    };
    std::vector<T> elem_;
    Node* previous_;
    std::vector<Node*> children_;
    size_t amount_;
  };
  size_t max;
  Node *root_, *head_, *tail_;


with the desctructor of Node i am getting some weird errors, normally i can work template errors out on my own but this error is rather long and hard to understand

btree.h:179: error: no match for 'operator~' in '~* it.__gnu_cxx::__normal_iterator<_Iterator, _Container>::operator* [with _Iterator = btree<long int>::Node**, _Container = std::vector<btree<long int>::Node*, std::allocator<btree<long int>::Node*> >]()'
/usr/include/c++/4.3/bits/ios_base.h:105: note: candidates are: std::_Ios_Fmtflags std::operator~(std::_Ios_Fmtflags)
/usr/include/c++/4.3/bits/ios_base.h:145: note:                 std::_Ios_Openmode std::operator~(std::_Ios_Openmode)
/usr/include/c++/4.3/bits/ios_base.h:183: note:                 std::_Ios_Iostate std::operator~(std::_Ios_Iostate)

note btree.h:179 refers to the line "~(**it);"
what am i doing wrong here? its an iterator so i need 1 * to dereference and then a second * to dereference the pointer, this should result in ~Node no?
I don't get it. Are you trying to call the destructor? If that's the case:
1. Destructors are not operators. The ~ that goes in front of the class name is merely syntactical. Everywhere else, ~ is the bitwise NOT operator.
2. Destructors can't be explicitly called. Either they are called when deleting a pointer, or automatically called when an object with automatic storage duration goes out of scope.
*smacks head*
cheers helios, dont know how the hell i thought i could call the destructor explicitly!!!
Topic archived. No new replies allowed.