---
title: "メンバーの隠蔽"
content_type: tutorial
url: "https://learn.unity.com/tutorial/member-hiding-jp?language=ja"
language: ja
difficulty: intermediate
duration_minutes: 5
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/member-hiding.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/ocultacion-de-miembros.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/member-hiding-jp.md?language=ja"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/cheng-yuan-yin-cang.md?language=zh-cn"
last_updated: "2026-08-04T14:23:55.000Z"
---

# メンバーの隠蔽

C# の継承で派生クラスから基底クラスのメンバーを隠蔽する方法を理解します。

派生クラスで基底クラスのメンバーの隠蔽を実装する方法を学びます。

## 1. メンバーの隠蔽

[Video](http://www.youtube.com/watch?v=n58yUg2V1lc)

**Humanoid クラスのコード**

```csharp
using UnityEngine;
using System.Collections;

public class Humanoid
{
    // Yell メソッドの基底クラスのバージョン
    public void Yell()
    {
        Debug.Log ("Humanoid version of the Yell() method");
    }
}
```

**Enemy クラスのコード**

```csharp
using UnityEngine;
using System.Collections;

public class Enemy : Humanoid
{
    // この記述により、Humanoid クラスのバージョンが隠蔽されます。
    new public void Yell()
    {
        Debug.Log ("Enemy version of the Yell() method");
    }
}
```

**Orc クラスのコード**

```csharp
using UnityEngine;
using System.Collections;

public class Orc : Enemy
{
    // この記述により、Enemy クラスのバージョンが隠蔽されます。
    new public void Yell()
    {
        Debug.Log ("Orc version of the Yell() method");
    }
}
```

**WarBand クラスのコード**

```csharp
using UnityEngine;
using System.Collections;

public class WarBand : MonoBehaviour 
{
    void Start () 
    {
        Humanoid human = new Humanoid();
        Humanoid enemy = new Enemy();
        Humanoid orc = new Orc();

        // Humanoid 型の各変数に継承の階層内にある、
        // 異なるクラスのオブジェクトへの参照が格納されることに注意してください。
        // この場合、各オブジェクトから
        // Humanoid クラスの Yell() メソッドが呼ばれます。
        human.Yell();
        enemy.Yell();
        orc.Yell();
    }
}
```
