What does the pointer 'this+1' refer to in C++?

Presumably this is part of an array, so this+1 would refer to the next object in that array.


this is simply a pointer which refers to this object. Since it's a pointer, you can apply pointer arithmetic and even array indexing.

If this object is an element in an array, this+1 would point to the next object in the array.

If it's not, well it's just going to treat whatever is at that memory the same as this object, which will be undefined behaviour unless it is the same type.


As it is NLP it makes sense to optimize memory management. I assume you find overloaded new/delete methods as well.

The this+1 construct assumes all objects reside in an array. The name 'childrenEnd' of the method indicates it returns a pointer to an address of the end of the children of the current node.

Thus you are looking at an implementation of a tree structure. All siblings are adjacent and their children as well.

Tags:

C++