|< < 35 > >|

Referential integrity

In C++

class Foo { Bar* bar; }; Foo* foo = new Foo(); ...

Possible values of foo->bar:

  • OK: The address of a Bar.
  • OK: NULL.
  • Don't do this: Random memory, (e.g. Bar on stack from function we've exited, deallocated Bar, ...). Reading or writing foo->bar is a bad idea.

Pointing into random memory violates referential integrity.

|< < 35 > >|