B+Tree

Hello

I wanted to know how do I use the void* to two kind of different structures

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  struct noInterno
{   int num_elems;
  // noInterno* pai[2];
    int chaves[4];
    void* filhos[5];
    bool isLeaf;
    int h;
};




struct noFolha
{   
    int num_elems;
    Regist* array[4];
    noFolha* prev;
    noFolha* next;
    bool isLeaf;
    int h;
};

noFolha* arvbmais::procura_noFolha(int elem, void* root)
 {  noFolha* a = (noFolha*) root;
    noInterno* b = (noInterno*) root;
    
   if(  (noFolha*) root->isLeaf  )
   return  root;

it gives me these errors:
In member function `noFolha* arvbmais::procura_noFolha(int, void*)':
`void*' is not a pointer-to-object type
invalid conversion from `void*' to `noFolha*'

i want to know how to reference it to a noFolha, and when I need, how to reference root to noInterno?

its an incomplete code for search b+tree,
Your error is due to you trying to return "root", which is a void pointer, at then end of your member function when you declared that the function would return a "noFolha" pointer.

Why are you casting data types anyway? There are far better ways to do this in C++ depending on your requirements.
Last edited on
I need to do a b+tree implementation, and i thought this kind of approach would be the best in terms o space.
Could kindly explain me which are the other ways to do it?

A B+ tree has two kind of nodes, leaf node and intern node, so I need a simple way to reference the kind of node that i will be using
Thanks for the help
Topic archived. No new replies allowed.