Algorithmic Solutions > LEDA > LEDA Guide > Geometry > Handle Types, Identity and Equality

## Handle Types, Identity and Equality

All geometric objects in LEDA are so-called handle types, i.e., an object of any geometric type is a (smart) pointer to a representation object. A `rat_point`, for example, is a pointer to a `rat_point_rep` and a `segment` is a pointer to a `segment_rep`. The objects of the representation class contain the defining information about the geometric object and possibly additional information for internal use.

### Distinction between Identical and Equal Objects

In the following we use `points` as an example. Similar statements are true for all geometric objects.

Two points `p` and `q` are identical (function `identical(p,q)`) if they point to the same `point_rep`.
Two `points` `p` and `q` are equal (binary operator `==`) if they agree as geometric objects, i.e., if they have the same Cartesian coordinates.

The assignment statement and the copy constructor preserve identity. They are implemented by pointer assignments.

### Example

The following program illustrates the difference between identity and equality. See Writing Kernel Independent Code for an explanation for writing POINT.

```#include <LEDA/point.h>
#include <LEDA/geo/float_kernel_names.h>

using namespace leda;

int main()
{
POINT p(0,0);
POINT q(0,0);
POINT r=p;

if (identical(p,q)) std::cout << "p and q are identical" << std::endl;
else std::cout << "p and q are not identical" << std::endl;
//evaluates to false

if (p==q) std::cout << "p and q are equal" << std::endl;
else std::cout << "p and q are not equal" << std::endl;
//evaluates to true

if (identical(p,r)) std::cout << "p and r are identical" << std::endl;
else std::cout << "p and q are not identical" << std::endl;
//evaluates to true

if (p==r) std::cout << "p and q are equal" << std::endl;
else std::cout << "p and q are not equal" << std::endl;
//evaluates to true

return 0;
}  ```

Data Types for 2D Geometry

Writing Kernel Independent Code

Geometry

Data Types for 3-D Geometry