# 10.3 指针和对象实现

## 一、概念

1.对象的多重数组表示：对一组具有相同域的对象，每一个对象都可以用一个数组来表示

![](http://windmissing.github.io/images_for_gitbook/Introduction_to_Algorithms/4.gif)

2.对象的单数组表示：一个对象占据存储中的一组连续位置

![](http://windmissing.github.io/images_for_gitbook/Introduction_to_Algorithms/5.gif)

## 二、代码

```cpp
int Allocate_Object()
{
    if(free == NULL)
    {
        cout<<"error:out of space"<<endl;
        exit(0);
    }
    else
    {
        int x = free;
        free = next[x];
        return x;
    }
}
void Free_Object(int x)
{
    next[x] = free;
    free = x;
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://windmising.gitbook.io/introduction-to-algorithms/di-10-zhang-zhan-he-dui-lie/introduction-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
