struct Question

my table.h file
1
2
3
4
5
6
7
8
private:
static const int size = 9;
struct test{
    bool Info;
    test *next;
};
		
 test*array[size];


my table.cpp
1
2
3
4
5
6
7
table::table()
{
  for(int i = 0; i < size; i++){
  array[i] = NULL;
  array[i].info = false; //ERROR HERE
  }
}


I am trying to set all my pointer to NULL(which works) but my bool info variable wont set to false. I need to use lazy deletion so every time I enter data into the array I want to set it to true. Could someone explain my error here?
When you have a pointer you have to first dereference the pointer (using operator*) to get what the pointer points to. You can then access the members of the object by using the dot operator (*array[i]).info. You can use the arrow operator as a shorthand array[i]->info for doing the same thing.

array[i] is null witch means that it doesn't point to any object. No object means that there is no info member that you can set to false.
Last edited on
Topic archived. No new replies allowed.