<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ja">
	<id>https://twiki.yo-net.jp/index.php?action=history&amp;feed=atom&amp;title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90</id>
	<title>Cpp クラス アクセス指定子 - 版の履歴</title>
	<link rel="self" type="application/atom+xml" href="https://twiki.yo-net.jp/index.php?action=history&amp;feed=atom&amp;title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90"/>
	<link rel="alternate" type="text/html" href="https://twiki.yo-net.jp/index.php?title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90&amp;action=history"/>
	<updated>2026-04-06T05:28:51Z</updated>
	<subtitle>このウィキのこのページに関する変更履歴</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://twiki.yo-net.jp/index.php?title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90&amp;diff=1626&amp;oldid=prev</id>
		<title>2022年10月25日 (火) 03:37にYo-netによる</title>
		<link rel="alternate" type="text/html" href="https://twiki.yo-net.jp/index.php?title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90&amp;diff=1626&amp;oldid=prev"/>
		<updated>2022-10-25T03:37:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ja&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← 古い版&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;2022年10月25日 (火) 12:37時点における版&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l40&quot;&gt;40行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;40行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Access_Specifiers001.h&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Access_Specifiers001.h&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;class CAccess_Specifiers001{&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;class CAccess_Specifiers001{&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   int  m_nValue;                    //★1.メンバ変数 省略されている場合はprivate:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;   int  m_nValue;                    //★1.メンバ変数 省略されている場合はprivate:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l69&quot;&gt;69行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;69行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Access_Specifiers001.cpp&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Access_Specifiers001.cpp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l136&quot;&gt;136行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;136行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;メインプログラムや他のクラス内で以下のようにクラスを実際に利用するプログラムを記述すると以下のようになります。&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;メインプログラムや他のクラス内で以下のようにクラスを実際に利用するプログラムを記述すると以下のようになります。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;と上記のように利用します。_tmain関数からの呼び出し処理がいわゆる外部からの呼び出しにあたる処理になります。クラスを説明した記事でも記sample_main.cpp&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;と上記のように利用します。_tmain関数からの呼び出し処理がいわゆる外部からの呼び出しにあたる処理になります。クラスを説明した記事でも記sample_main.cpp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l165&quot;&gt;165行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;165行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Access_Specifiers001.cpp&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Access_Specifiers001.cpp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;…&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;…&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;省略&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;省略&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l209&quot;&gt;209行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;209行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IntUnit.h&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IntUnit.h&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#pragma once&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#pragma once&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;access_specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;access_specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l226&quot;&gt;226行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;226行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IntUnit.h&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IntUnit.h&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#pragma once&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#pragma once&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;access_specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;access_specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l242&quot;&gt;242行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;242行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IntUnit.cpp&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;IntUnit.cpp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;IntUnit.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;IntUnit.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l265&quot;&gt;265行目:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;265行目:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;具体的には以下のようなプログラムになります。&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;具体的には以下のようなプログラムになります。&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;sample_main.cpp&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;sample_main.cpp&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;1&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&amp;quot;&lt;/del&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=1&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;-1+1&lt;/ins&gt;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;stdafx.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Yo-net</name></author>
	</entry>
	<entry>
		<id>https://twiki.yo-net.jp/index.php?title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90&amp;diff=98&amp;oldid=prev</id>
		<title>Yo-net: ページの作成:「C++に戻る   &lt;table class=&quot;mbox-small&quot; style=&quot;border:1px solid #aaa; background-color:#f9f9f9; width:22em;&quot; id=&quot;RealTitleBanner&quot;&gt; &lt;tr&gt; &lt;td style=&quot;width:1px;&quot;&gt;&lt;/td&gt; &lt;td class=&quot;mbox-text plainlist&quot; style=&quot;&quot;&gt;本来の表記は「&lt;b&gt;&lt;span id=&quot;RealTitle&quot; style=&quot;font-size:large;&quot;&gt;C++(Cpp) クラス アクセス指定子&lt;/span&gt;&lt;/b&gt;」です。この記事に付けられた題名は{{記事名の制約}}から不正確なものとなっ…」</title>
		<link rel="alternate" type="text/html" href="https://twiki.yo-net.jp/index.php?title=Cpp_%E3%82%AF%E3%83%A9%E3%82%B9_%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E6%8C%87%E5%AE%9A%E5%AD%90&amp;diff=98&amp;oldid=prev"/>
		<updated>2022-09-26T02:09:38Z</updated>

		<summary type="html">&lt;p&gt;ページの作成:「&lt;a href=&quot;/C_PlusPlus#C++からの技術&quot; title=&quot;C PlusPlus&quot;&gt;C++&lt;/a&gt;に戻る   &amp;lt;table class=&amp;quot;mbox-small&amp;quot; style=&amp;quot;border:1px solid #aaa; background-color:#f9f9f9; width:22em;&amp;quot; id=&amp;quot;RealTitleBanner&amp;quot;&amp;gt; &amp;lt;tr&amp;gt; &amp;lt;td style=&amp;quot;width:1px;&amp;quot;&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;td class=&amp;quot;mbox-text plainlist&amp;quot; style=&amp;quot;&amp;quot;&amp;gt;本来の表記は「&amp;lt;b&amp;gt;&amp;lt;span id=&amp;quot;RealTitle&amp;quot; style=&amp;quot;font-size:large;&amp;quot;&amp;gt;C++(Cpp) クラス アクセス指定子&amp;lt;/span&amp;gt;&amp;lt;/b&amp;gt;」です。この記事に付けられた題名は{{記事名の制約}}から不正確なものとなっ…」&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新規ページ&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[C PlusPlus#C++からの技術|C++]]に戻る&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;table class=&amp;quot;mbox-small&amp;quot; style=&amp;quot;border:1px solid #aaa; background-color:#f9f9f9; width:22em;&amp;quot; id=&amp;quot;RealTitleBanner&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td style=&amp;quot;width:1px;&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td class=&amp;quot;mbox-text plainlist&amp;quot; style=&amp;quot;&amp;quot;&amp;gt;本来の表記は「&amp;lt;b&amp;gt;&amp;lt;span id=&amp;quot;RealTitle&amp;quot; style=&amp;quot;font-size:large;&amp;quot;&amp;gt;C++(Cpp) クラス アクセス指定子&amp;lt;/span&amp;gt;&amp;lt;/b&amp;gt;」です。この記事に付けられた題名は{{記事名の制約}}から不正確なものとなっています。&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
※このページでは[[C PlusPlus|C++]]にのみ存在する機能として、記事タイトルが&amp;lt;nowiki&amp;gt;C++ クラス アクセス指定子&amp;lt;/nowiki&amp;gt;になっています。&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
== '''クラス アクセス指定子''' ==&lt;br /&gt;
&lt;br /&gt;
クラス宣言をするヘッダファイル側で指定するアクセス指定子は、クラスの利用時の基本的な制約を指定するものです。クラスとはじめて向き合った人は、なんのこっちゃわからんという感じになりやすい部分だと思います。クラスを利用するときの基本的な使い方を理解していないと、どうしても、このアクセス指定子の意味がわかり辛く感じるのだと思います。クラスの基本的な利用方法については既に[[Cpp クラス|クラス]]の項目に記述しましたので、軽く理解しておいたほうが良いと思います。クラスで行われる隠蔽の技術の解説についてもこの項目で長々と記述する予定です。まずは簡単な説明から記述します。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
アクセス指定子には3種類のアクセスレベルが用意されています。&lt;br /&gt;
&lt;br /&gt;
*public&lt;br /&gt;
:クラスの外側からも呼び出しできる関数や変数になる。&lt;br /&gt;
&lt;br /&gt;
*protected&lt;br /&gt;
:クラス内部や派生されたクラスからも呼び出しできる関数や変数になる。publicとprivateの中間的なアクセスレベル。&lt;br /&gt;
&lt;br /&gt;
*private&lt;br /&gt;
:省略時の規定値。クラスの外側からは呼び出しできない関数や変数になる。つまり、クラス内部のみ呼び出しできるということ。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
と簡単に説明しましたが、初めてクラスというものを使おうとする人にとっては、上記の簡単なまとめだけでは、まだしっくり来ないかもしれません。具体的に使ってみて理解しましょう。そして、クラスの内部とか外部とか、派生とかという表現の意味についても説明します。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
C言語では、こんなのなかったんだから、覚えなくっても大丈夫ってわけには行かないのがアクセス指定子です。これを理解しないと、クラスを使うことはできないし、あやつることは出来ません。誰かが定義したクラスとかだと、うまくアクセス指定がされていて、クラス内のこの変数を変更すれば、プログラムの動作が変更されるのは、なんとなくわかるんだけど…変更しようとするとなんかコンパイルエラーが出まくって、使いこなせないイライラ！ってことになってしまいます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
この先の記述はだいたい、うっすらわかっている人にはまどろっこしい説明が続くかもしれませんが、半分くらい理解してる人でも、継承して派生させる場合にもアクセス指定子が使えるので、そのあたりの説明はもう少し先の方に記述しますので、派生時の一括定義に関するアクセス指定の件について理解していない人は、軽く下の方まで目をとおしておいた方が良いと思います。わかったつもりになるのが、プログラムを理解する上で一番危険なことです。あらゆる学問もそうだと思いますが…&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
それでは、派生とか継承とか内部とか外部とか、意味の分からないキーワードを理解していくためにも具体的に使ってみます。以下は説明用の単純なサンプルクラスです。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Access_Specifiers001.h&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
class CAccess_Specifiers001{&lt;br /&gt;
  int  m_nValue;                    //★1.メンバ変数 省略されている場合はprivate:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public:                             //★2.この宣言からpublic:&lt;br /&gt;
  int  mpub_nValue;&lt;br /&gt;
&lt;br /&gt;
  void Set_m_nValue(int nSetValueP);//メンバ関数 &lt;br /&gt;
  int  Get_m_nValue();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
protected:                          //★3.この宣言からprotected:&lt;br /&gt;
  wchar_t m_wcUnit;&lt;br /&gt;
&lt;br /&gt;
  void mf_m_nValue1000x();&lt;br /&gt;
  void mf_m_nValuePermil();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
private:                            //★4.明示的なprivate:&lt;br /&gt;
  int  m_nManipulatorCnt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public:&lt;br /&gt;
  CAccess_Specifiers001(void);&lt;br /&gt;
  ~CAccess_Specifiers001(void);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Access_Specifiers001.cpp&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void CAccess_Specifiers001::Set_m_nValue(int nSetValueP){&lt;br /&gt;
  m_nValue = nSetValueP;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int  CAccess_Specifiers001::Get_m_nValue(){&lt;br /&gt;
  return m_nValue;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void CAccess_Specifiers001::mf_m_nValue1000x(){&lt;br /&gt;
  m_nValue = m_nValue * 1000;&lt;br /&gt;
  m_nManipulatorCnt++;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void CAccess_Specifiers001::mf_m_nValuePermil(){&lt;br /&gt;
  m_nValue = m_nValue / 1000;&lt;br /&gt;
  m_nManipulatorCnt--;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
     CAccess_Specifiers001::CAccess_Specifiers001(void)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
     CAccess_Specifiers001::~CAccess_Specifiers001(void)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
という具合のサンプルクラスを作ってみました。サンプルの割に長くなってしまいましたが、なんとなく1000倍したり1000分の1にしたりするだけの操作をするクラスです。今のところ欠陥だらけのクラスになっています。実現しようとしているクラスの機能として欠陥があるだけで、コンパイル・リンク処理は出来ます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
まずはアクセス指定子の具体的な利用部分について説明しておきます。&lt;br /&gt;
&lt;br /&gt;
★1.部分のようにアクセス指定子を記述しないでクラスの中の定義を書き始めると、その部分はprivateを指定したのと同じ意味で変数や関数が定義されます。クラス内部からしか呼び出し出来ないという表現をしましたが、内部というキーワードについてはもう少し後での説明になります。変数名のプレフィックス(接頭語)としてm_をつけるのはクラスの使い方における基本的な変数命名法として定着しているものです。あとは自分独自の命名法になります。このWikiの記事を最初から全部読んでいる人には、管理人の独自の命名法について説明したと思いますので、それについては割愛します。変数名の付け方は自由です。ちょっとわかりにくい日本語を使うなら任意(にんい)ともいいますね。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
次に&lt;br /&gt;
&lt;br /&gt;
★2.部分で具体的にアクセス指定子を明示した部分が登場します。&lt;br /&gt;
&lt;br /&gt;
アクセス指定子''':'''&lt;br /&gt;
&lt;br /&gt;
のように:を使って終端を修飾します。この指定の後ろからアクセス指定の意味が変更されるということになります。ここではpublicを指定したので、この先で指定した関数や変数からは、クラスの外部からも呼び出し出来ることになります。外部というキーワードについても後程の説明になります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
そして&lt;br /&gt;
&lt;br /&gt;
★3.部分には新たにprotectedのアクセス指定子を使いました。内部と継承で派生したクラスから呼び出せる変数や関数の定義になります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
最後に&lt;br /&gt;
&lt;br /&gt;
★4.部分でprivateのアクセス指定子を使っています。またクラス内部だけの呼び出しが許される変数や関数の定義に切り替わります。このように何度でもアクセス指定子は使えます。繰り返し使えますが、通常はまとめて記述する人が多いです。何の設計図もなく、1000倍や1000分の1倍するような機能を持つクラスを作り、適当にアクセス指定子を割り振っていますので、この先、都合が悪くなるとアクセス指定子の設定を変更するかもしれません。今のところ、1000分の1にしたとき小数になるから、int型だけだと都合が悪くなりそうなことだけは気づいてますが、そのままにしています。あとでプログラムを変更することになるでしょう。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
たったこれだけの説明で、これだけ長くなってしまいました。記事全体が相当長くなりそうな気配がぷんぷんとしてきました。基本中の基本のことがらをこれだけ冗長的に説明するのは体が持たないような気がしますし、読んでる人も疲れるから、あまり良い記事にはならない気がしますね。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''ついてこれるヤツだけ、ついて来い！'''(なんつって、振り返ったら誰もついてきてない感じの風景が明確に想像できます。)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
メインプログラムや他のクラス内で以下のようにクラスを実際に利用するプログラムを記述すると以下のようになります。&lt;br /&gt;
と上記のように利用します。_tmain関数からの呼び出し処理がいわゆる外部からの呼び出しにあたる処理になります。クラスを説明した記事でも記sample_main.cpp&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int _tmain(int argc, _TCHAR* argv[])&lt;br /&gt;
{&lt;br /&gt;
  printf(&amp;quot;★アクセス指定子\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  int nValue;&lt;br /&gt;
  CAccess_Specifiers001* CAccess_Specifiers001_Instance = new CAccess_Specifiers001;&lt;br /&gt;
  &lt;br /&gt;
  CAccess_Specifiers001_Instance-&amp;gt;Set_m_nValue(120);&lt;br /&gt;
  &lt;br /&gt;
  nValue = CAccess_Specifiers001_Instance-&amp;gt;Get_m_nValue();&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;%d\n&amp;quot;,nValue);&lt;br /&gt;
&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
述しましたが、Access_Specifiers001.hファイルの★1.部分にあるようなm_nValueというint型の変数にはprivateというアクセス指定がなされていて、内部からの呼び出しだけが許されています。したがって、_tmain関数から呼び出すことはできないため、CAccess_Specifiers001_Instance-&amp;gt;m_nValue = 120;のように変数の呼び出しをしようとするとコンパイルエラーになります。値を設定するにはSet_m_nValue関数を値を取得するにはGet_m_nValue関数を使うしかないのがCAccess_Specifiers001の取り決めになります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
これは何のために、こんなまどろっこしいことになっているのでしょうか？今のところのプログラムでは直接、m_nValueの値を設定できた方が良さそうに感じます。実はこのクラスはm_nValueには-999～999の値を最初に設定してほしいという規制を作りたいとします。そうするとSet関数内でその新たに規制のための処理を追加すれば良くて、直接に変数を呼び出して値を設定をすることはできないということが、クラスという機能を使う考え方になっています。そのためにアクセス指定子によって、直接に変数を呼び出すことを制御できることになります。このような仕組みを隠蔽と呼んでいます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
クラスのメンバ関数もメンバ変数と同じで、呼び出されるとまずい関数を作りたくなったりする場合が生じてきます。では、実際にサンプルプログラムのAccess_Specifiers001.cppの内容を書き換えて、設定値に関する規制を作ろうと思います。以下のようになります。&lt;br /&gt;
&lt;br /&gt;
Access_Specifiers001.cpp&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
…&lt;br /&gt;
省略&lt;br /&gt;
…&lt;br /&gt;
void CAccess_Specifiers001::Set_m_nValue(int nSetValueP){&lt;br /&gt;
  if(m_nValue &amp;lt;= -1000 || m_nValue &amp;gt;=1000){&lt;br /&gt;
    printf(&amp;quot;Warning:Set_m_nValue関数で認められない値が設定されました。(Limit -999～999)\n&amp;quot;);&lt;br /&gt;
  }&lt;br /&gt;
  else{&lt;br /&gt;
    m_nValue = nSetValueP;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
…&lt;br /&gt;
省略&lt;br /&gt;
…&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
ちょっと冷たいエラーメッセージですが、とりあえず規制されました。Windowsとかのダイアログでの入力だと入れようとするとOKボタンが押せないとか、そういう感じの冷たさのエラーがでるのと同じです。親切ならOKボタンを押したときに、エラー値が入れられた値の欄を明示して、どの値がダメとか丁寧なエラーを出したり、入力したとたんエラーをしめすような、入力欄の名前の部分や、値そのものが赤色の文字になって不正であることを示したりします。ここでは、当初の目標であるアクセス指定子を出来るだけ丁寧に説明するというだけのサンプルであるという雑さをもちあわせたまま、無理やりにサンプルを作ります。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ク、クラス恐るべしだな。ひとつの機能の塊をもつのがクラスだから、こんな指定があるので、覚えるしかないですが、最初にこの技術をしったとき、こういった説明を読んでも尚、まだ納得してませんでした。ややこしい仕組みだなぁ。こんなのつかわなくてもプログラムなんてやれると反抗的な態度だった若かりし頃の自分を思い出します。最近の若い人はどんな風に感じるんだろうか。ICT社会だから、すぐ納得できるんだろうか。心配です。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
とにもかくにもクラスの中で定義されてるメンバ関数から呼び出すのが内部(Access_Specifiers001.cpp内で記述している関数)で、それ以外は外部(上の例なら_tmain関数)ってことです。それが内部と外部です。わかっていただけていたら幸せなことです。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
じゃ、あとはprotectedで説明した派生したクラスと内部だけっていうパターンを説明する感じですね。これは別の項目でも継承って奴について記述するつもりなので詳細は継承の記事を読んでもらえるといいんですけど、まずは簡単に派生ってやつのパターンを示したいと思います。でも、今日はここまでかな。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
では、難しいことは考えずに継承ってやつを使ったクラスを作ってみます。継承に関する詳細は継承の記事で触れますので、ここでは継承というものが存在しいるとだけ、なんとなく理解しておくとよいと思います。VisualStudioでは具体的に以下のように操作すると、ここで作ったCAccess_Specifiers001ってやつを継承したクラスを作ることができます。新しく作るクラス名はCIntUnitとすることにします。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Visual Studioのメニュー プロジェクトからクラスの追加を選択します。&lt;br /&gt;
&lt;br /&gt;
[[file:CppClassAdd01.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
表示されたダイアログのクラス名にCIntUnit そして、基本クラスにCAccess_Specifiers001と指定します。継承しない(派生しない)クラスを作るときは基本クラスの欄は何もいれないでクラスを作ることができます。 プロジェクトからクラスの追加を選択します。&lt;br /&gt;
&lt;br /&gt;
[[file:CppClassAdd02.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
そうすると、CIntUnitは派生したクラスになり、継承と言う技術を使っていて、継承の基本クラスにCAccess_Specifiers001だけが選択されていることになります。クラスの定義は以下のように自動生成されます。&lt;br /&gt;
&lt;br /&gt;
IntUnit.h&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#pragma once&lt;br /&gt;
#include &amp;quot;access_specifiers001.h&amp;quot;&lt;br /&gt;
class CIntUnit : public CAccess_Specifiers001//★5.継承&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
  CIntUnit(void);&lt;br /&gt;
  ~CIntUnit(void);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
★5.の部分で定義されたクラスは派生していないクラスと違って、上記の3行目のようにclass CIntUnit : public CAccess_Specifiers001 としてクラス定義がなされます。これがCAccess_Specifiers001を継承した派生クラスCIntUnitを定義する方法です。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
通常の定義したクラスと違って、CIntUnitはCAccess_Specifiers001の機能をすべて持っていて、protectedおよびpublicで定義された関数や変数にはアクセスできるようになっています。CIntUnitは派生してるクラスなのでCAccess_Specifiers001のメンバ変数m_nValueを1000倍してくれる関数が使えます。実際にやってみましょう。まずCIntUnitにCAccess_Specifiers001のmf_m_nValue1000x()を呼び出す関数mf_1000x();を定義してみます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
IntUnit.h&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#pragma once&lt;br /&gt;
#include &amp;quot;access_specifiers001.h&amp;quot;&lt;br /&gt;
class CIntUnit :&lt;br /&gt;
  public CAccess_Specifiers001&lt;br /&gt;
{&lt;br /&gt;
public:&lt;br /&gt;
  void mf_1000x(void);//★6.protectedで定義された関数を使うクラス。&lt;br /&gt;
&lt;br /&gt;
  CIntUnit(void);&lt;br /&gt;
  ~CIntUnit(void);&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
★6.のようにmf_1000xという関数を作りました。&lt;br /&gt;
&lt;br /&gt;
IntUnit.cpp&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
#include &amp;quot;IntUnit.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
void CIntUnit::mf_1000x(){&lt;br /&gt;
  mf_m_nValue1000x();//★7._tmain関数では呼び出せなかったが、派生クラスからは呼び出せる。&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
CIntUnit::CIntUnit(void)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CIntUnit::~CIntUnit(void)&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
CIntUnit.cppのプログラム部分にmf_1000xの処理として、_tmain関数から作ったクラスでは直接呼べなかったmf_m_nValue1000xを呼び出すように★7.部分のように記述しました。このように派生したクラスからはprotectedでアクセス指定子が宣言されている関数にできるのが派生クラスの権限です。そうするとCIntUnitクラスを使えばCAccess_Specifiers001クラスではできなかった処理ができることになります。このようにprotectedのレベルで定義された関数は派生クラスによって正しい使い方を定義してくれるのを期待して、直接呼べなくする関数や変数にする役割を持たせることができると考えてよいでしょう。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
具体的には以下のようなプログラムになります。&lt;br /&gt;
sample_main.cpp&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;cpp&amp;quot; line start=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
#include &amp;quot;Access_Specifiers001.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
int _tmain(int argc, _TCHAR* argv[])&lt;br /&gt;
{&lt;br /&gt;
  printf(&amp;quot;★アクセス指定子\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  int nValue;&lt;br /&gt;
  CAccess_Specifiers001* CAccess_Specifiers001_Instance = new CAccess_Specifiers001;&lt;br /&gt;
  &lt;br /&gt;
  CAccess_Specifiers001_Instance-&amp;gt;Set_m_nValue(120);&lt;br /&gt;
  &lt;br /&gt;
  nValue = CAccess_Specifiers001_Instance-&amp;gt;Get_m_nValue();&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;%d\n&amp;quot;,nValue);&lt;br /&gt;
&lt;br /&gt;
  //CAccess_Specifiers001_Instance-&amp;gt;mf_m_nValue1000x();★8.protectedのメンバ関数なので呼び出せない。&lt;br /&gt;
&lt;br /&gt;
  nValue = CAccess_Specifiers001_Instance-&amp;gt;Get_m_nValue();&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;%d\n&amp;quot;,nValue);&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;CIntUnit派生クラス\n&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
  CIntUnit* CIntUnit_Instance = new CIntUnit;&lt;br /&gt;
&lt;br /&gt;
  CIntUnit_Instance-&amp;gt;Set_m_nValue(240);&lt;br /&gt;
&lt;br /&gt;
  nValue = CIntUnit_Instance-&amp;gt;Get_m_nValue();&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;%d\n&amp;quot;,nValue);&lt;br /&gt;
&lt;br /&gt;
  CIntUnit_Instance-&amp;gt;mf_1000x();//★9.派生したクラスからだと呼び出しが出来る。&lt;br /&gt;
&lt;br /&gt;
  nValue = CIntUnit_Instance-&amp;gt;Get_m_nValue();&lt;br /&gt;
&lt;br /&gt;
  printf(&amp;quot;%d\n&amp;quot;,nValue);  return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
★8.は呼び出せませんでしたが、★9.からは呼び出せます。今回のサンプルだと、なぜprotectedにしたのか明確な理由が見いだせていませんが、例えば、派生クラスではm_wcUnitを使って単位文字列の管理をしてくれることを期待しているとしたら、基本クラス設計者の期待を裏切っていることになるやもしれません。今回は自分であえて、基本クラスの理念を守らなかっただけなので、雑な派生クラスを作ったというところになります。このようにアクセス指定子には意味があるし、派生クラスに期待されていることもいくつかあるということになります。といわれても英語の文書しかない基本クラスが配布されたとして、こうやって作られた基本クラスの意図していることを、素人プログラマが理解することは、なんつうか無理があるので、使い方がわからないままにおわったり、クラスを使うことに縛られて、どうしたらいいのかわからなくなるということが起こります。こんな感じでアクセス指定子が複雑に設定されているだけで、なんとなくクラスの設計時に期待されていることがあるということがわかっていただけたら、それでこの項目で言いたかったことは伝わったように感じます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
他にもクラスの定義で使われるいろいろなメカニズムによって基本クラスの設計者が派生クラスを生成したときの使い方で期待していることがなんなのかを予想することができるし、それを予想しなければ、うまく派生クラスを使いこなせないし、クラス自体も使いこなせないということに繋がります。もちろん、今回のサンプルのように意図していない使い方で無理やり使って、やりたいことが実現できれば、それはそれで問題ないわけです。&lt;br /&gt;
&lt;br /&gt;
そんな感じで無理やり動かすように作成したプログラムの動作結果は以下のようになりました。見事に1000倍されています。派生したクラスは基本クラスの機能のすべてをひきついでいるということを理解しないと、sample_main.cppでのCIntUnitの使われ方について、よく意味がわからなかったかもしれませんが、アクセス制御についてなんとなく理解はしてもらえたかなと思います。&lt;br /&gt;
&lt;br /&gt;
出力結果&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
★アクセス指定子&lt;br /&gt;
120&lt;br /&gt;
120&lt;br /&gt;
CIntUnit派生クラス&lt;br /&gt;
240&lt;br /&gt;
240000&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
もうひとつ、アクセス指定子に関して、補足しておかなければならないことがありまして、★5.部分のように継承をするときにもアクセス指定子を使うことができることについて触れなければなりません。★5.部分では以下のように継承したクラスの宣言を記述しました。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''class CIntUnit : public CAccess_Specifiers001'''{&lt;br /&gt;
…&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
このように&lt;br /&gt;
&lt;br /&gt;
class (新規派生クラス名) : (アクセス指定子) (基本クラス名)&lt;br /&gt;
&lt;br /&gt;
のようにして継承が定義できます。アクセス指定子は省略することもできます。省略した場合はprivateと同じになります。今回のサンプルプログラムの場合は省略するとコンパイルエラーになります。これはどういうことかというと、継承時に記述するアクセス指定子は基本クラスの中のアクセス指定を一括して書き換えて、継承(すべての関数を引き継ぐ)するために、基本クラスの中のメンバ変数やメンバ関数のすべてがpraivateのアクセスレベルになって派生クラスで利用できるようになります。せっかく引き継いでも、アクセスできないので、_tmainから利用に関しては基底クラスの変数や関数において、何も使えるものはないといってよいと思います。派生したクラスではprotectedとpublicの関数や変数は使えます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
今回のように★5.の部分でpublicが指定されている場合は、アクセス指定子は基本クラスの内容と変わらずに使えることになります。したがって、_tmain関数からも基本クラスの変数でpublicが定義されている変数や関数を呼び出すことができるためSet_m_nValueにアクセスできます。publicが指定されているからと言って格上げされることはないため、privateやprotectedの変数や関数は呼び出しできません。基本クラスで指定したアクセス指定がそのままだということです。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
★5.の部分でprotectedが指定された場合は、publicで指定されていた部分がprotectedのレベルに引き下げられ、やはり_tmain関数からは呼び出しができなくなります。派生クラスからは、publicとprotectedの両方のアクセスレベルのものへ呼び出しができます。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
以上でアクセス指定子の説明は終了です。ここのサンプルで登場した1000倍したり1000分の1にしたりして単位を制御しようとか考えたクラスはこのまま放置するかもしれませんし、ひょっとしたら、このあとの記事で使いまわしてみるかもしれません。あまりサンプルに意味をもたせると、プログラムの内容にばかり理解力が奪われ、本来、簡単に深く知りたかったはずの事柄がないがしろになる恐れもあるという。どうしようか迷ってます。プログラム技術の説明って、いろいろと難しい。時間が有り余っている人は、単位変換まで含めてものすごいクラスを作っちゃってください。速度[m/s]* 時間[s] = 距離[m]とか、全部もうらすると科学技術計算が少しわかりやすくなるかもです。既にあるかもしれませんが。たかがサンプルでそういうことをしようかと思ったりして、壮大すぎる（汗。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[C PlusPlus#C++からの技術|C++]]に戻る&lt;/div&gt;</summary>
		<author><name>Yo-net</name></author>
	</entry>
</feed>