# 1.17 Structures

C++'da yapılar (structures), farklı türlerdeki verileri bir arada tutmak için kullanılan bir veri yapısıdır. Yapılar, birden fazla değişkeni bir araya getirerek tek bir veri türü gibi kullanılmasına olanak tanır. Bu, özellikle ilişkili verilerin birlikte saklanması gerektiğinde kullanışlıdır.

**Yapı Tanımlama**

Yapılar, `struct` anahtar kelimesi ile tanımlanır. Bir yapı tanımlarken, içerdiği değişkenlerin türü ve adı belirtilir.

**Örnek: Yapı Tanımlama**

```cpp
#include <iostream>
using namespace std;

// Yapı tanımı
struct Person {
    string name;
    int age;
};

int main() {
    // Yapı kullanarak bir değişken tanımlama
    Person person1;
    
    // Değişkenlere değer atama
    person1.name = "Hüseyin Tazegül";
    person1.age = 26;

    // Değerleri yazdırma
    cout << "İsim: " << person1.name << endl;
    cout << "Yaş: " << person1.age << endl;

    return 0;
}
```

**Yapı ile Fonksiyon Kullanımı**

Yapılar, fonksiyonlara parametre olarak da geçirilebilir. Bu, yapıların daha modüler ve yeniden kullanılabilir olmasını sağlar.

**Örnek: Yapı ile Fonksiyon Kullanımı**

```cpp
#include <iostream>
using namespace std;

// Yapı tanımı
struct Person {
    string name;
    int age;
};

// Yapı parametresi alan fonksiyon
void printPerson(Person p) {
    cout << "İsim: " << p.name << endl;
    cout << "Yaş: " << p.age << endl;
}

int main() {
    Person person1;
    person1.name = "Hüseyin Tazegül";
    person1.age = 26;

    // Fonksiyona yapı gönderme
    printPerson(person1);

    return 0;
}
```

**Yapılar ve Dizi Kullanımı**

Yapılar, dizilerle birlikte kullanılabilir. Bu, birden fazla benzer yapı nesnesini depolamak için kullanışlıdır.

**Örnek: Yapılar ve Dizi Kullanımı**

```cpp
#include <iostream>
using namespace std;

// Yapı tanımı
struct Person {
    string name;
    int age;
};

int main() {
    // Yapı dizisi tanımlama
    Person people[3];

    // Dizi elemanlarını doldurma
    people[0] = {"Ali", 30};
    people[1] = {"Ayşe", 25};
    people[2] = {"Mehmet", 28};

    // Dizi elemanlarını yazdırma
    for (int i = 0; i < 3; i++) {
        cout << "İsim: " << people[i].name << ", Yaş: " << people[i].age << endl;
    }

    return 0;
}
```


---

# 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://docs.yavuzlar.org/egitim/c-plus-plus/2.0-fonksiyonlar/1.17-structures.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.
