<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>イテルの一日一問 &#187; 継承</title>
	<atom:link href="http://oneday.ter.jp/tag/%e7%b6%99%e6%89%bf/feed" rel="self" type="application/rss+xml" />
	<link>http://oneday.ter.jp</link>
	<description>一日にひとつは何かを考える。</description>
	<lastBuildDate>Tue, 25 May 2010 00:35:11 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/tag/%e7%b6%99%e6%89%bf/feed" />
		<item>
		<title>継承4</title>
		<link>http://oneday.ter.jp/actionscript3/686.html</link>
		<comments>http://oneday.ter.jp/actionscript3/686.html#comments</comments>
		<pubDate>Wed, 12 Aug 2009 11:01:41 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[ポリモーフィズム]]></category>
		<category><![CDATA[多様態]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=686</guid>
		<description><![CDATA[
継承というのがいまいちどんなときに使ったら良いのかが
分からなかったが、テキストに書いてあることでざくっと分かった気がする。

コードの再利用性を高める役割。
理論的な階層構造を構築する役割。
オブジェクトの複数のタイ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://oneday.ter.jp/wp-content/uploads/2009/08/0908111.jpg" rel="shadowbox[post-686];player=img;"><img src="http://oneday.ter.jp/wp-content/uploads/2009/08/0908111-700x200.jpg" alt="090811" title="090811" width="700" height="200" class="alignnone size-thumbnail wp-image-720" /></a></p>
<p>継承というのがいまいちどんなときに使ったら良いのかが<br />
分からなかったが、テキストに書いてあることでざくっと分かった気がする。</p>
<ol>
<li>コードの再利用性を高める役割。</li>
<li>理論的な階層構造を構築する役割。</li>
<li>オブジェクトの複数のタイプを、ある単一のタイプが求められる場所で使用できる。</li>
</ol>
<h3>ポリモーフィズム（未解決）</h3>
<p>3番目の「オブジェクトの複数のタイプを、ある単一のタイプが求められる場所で使用できる。」？<br />
どういうこと？<br />
しかも、これを「ポリモーフィズム」というらしい。</p>
<p>ポリモーフィズム＝多様態。<br />
いや分からん。</p>
<blockquote><p>サブクラスのインターフェイスはそのスーパークラスの<br />
インスタンスが期待できる場所ならどこでも使用できます。</p></blockquote>
<p>たぶん、同じコードを何回も書くのはメンドイから、<br />
それを書かなくてもいいようにできるってことみたい。</p>
<p>これならなんとなく意味が分かりそうだけど、言及するのはやめとこ。<br />
これでとりあえず、継承の学習は終了ということで。<br />
まだまだ足りないし、未解決の部分もあるけど、<br />
分かるようになったら、また立ち戻ることにした。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/686.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/686.html" />
	</item>
		<item>
		<title>継承3</title>
		<link>http://oneday.ter.jp/actionscript3/682.html</link>
		<comments>http://oneday.ter.jp/actionscript3/682.html#comments</comments>
		<pubDate>Tue, 11 Aug 2009 11:00:44 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[コンストラクタメソッド]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=682</guid>
		<description><![CDATA[
正直、内容が難しくなって、as3の勉強から逃げてた。
逃げちゃダメだ、逃げちゃダメだ。
でも仕方ないよね。
「にんげんだもの。」
ということで、引き続きas3の継承の勉強を続ける。
サブクラス内のコンストラクタメソッド [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://oneday.ter.jp/wp-content/uploads/2009/08/090811.jpg" rel="shadowbox[post-682];player=img;"><img src="http://oneday.ter.jp/wp-content/uploads/2009/08/090811-700x200.jpg" alt="090811" title="090811" width="700" height="200" class="alignnone size-thumbnail wp-image-717" /></a></p>
<p>正直、内容が難しくなって、as3の勉強から逃げてた。<br />
逃げちゃダメだ、逃げちゃダメだ。<br />
でも仕方ないよね。<br />
「にんげんだもの。」</p>
<p>ということで、引き続きas3の継承の勉強を続ける。</p>
<h3>サブクラス内のコンストラクタメソッドの呼び出し</h3>
<p>「サブクラス内」の「コンストラクタメソッド」と言葉にすると意味が分からん。<br />
コンストラクタメソッドっていうのは、前もやったけどclassで最初に呼び出される<br />
プログラムのことだったと思う。</p>
<p>継承したクラスから親クラスのコンストラクタメソッドを呼び出すってことかな？<br />
それをするには「super()」を使うらしい。</p>
<pre class="brush: as3;">
//class A
public class A {
	//コンストラクタ
	public function A{
	}
}

//class Aを継承したB
public class B extends A{
	//サブクラスのコンストラクタ
	public function B{
		//スーパークラスのコンストラクタメソッドの呼び出し
		super();
	}
}
</pre>
<p>なんかますます分からんようになったかも。<br />
実際に使う現場に直面しないとダメね。<br />
今日はここまで。<br />
これをすると、親クラスAのコンストラクタメソッドが呼び出されるってことか。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/682.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/682.html" />
	</item>
		<item>
		<title>継承2（extends）</title>
		<link>http://oneday.ter.jp/actionscript3/596.html</link>
		<comments>http://oneday.ter.jp/actionscript3/596.html#comments</comments>
		<pubDate>Sun, 02 Aug 2009 14:26:14 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[継承]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=596</guid>
		<description><![CDATA[
昨日に引き続き、継承を学習する。
静的メソッドと静的変数は継承されない
読んで字のごとくです。

public class iteru{
	public static function hand(){
		trace( [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-thumbnail wp-image-598" title="090705-one31" src="http://oneday.ter.jp/wp-content/uploads/2009/08/090705-one311-700x200.jpg" alt="090705-one31" width="700" height="200" /></p>
<p>昨日に引き続き、継承を学習する。</p>
<h3>静的メソッドと静的変数は継承されない</h3>
<p>読んで字のごとくです。</p>
<pre class="brush: as3;">
public class iteru{
	public static function hand(){
		trace(&quot;iteru.hand()が呼び出されました。&quot;)
	}
}
public class koIteru extends iteru{
	public function koIteru(){
		koIteru.hand(); //→エラーになる！！！
	}
}
</pre>
<p>ということ。</p>
<h3>インスタンスメソッドのオーバーライド</h3>
<pre class="brush: as3;">
public class Iteru{
	//スーパークラス内でのインスタンスメソッドの宣言
	public function hand(){
		trace (&quot;Iteruのhandが呼び出された&quot;)
	}
}

//クラスKoIteruのコード
//handをオーバーライドする
public class KoIteru extends Iteru{
	override public function hand(){
		trace(&quot;KoIteruのhandが呼び出された&quot;);
	}
}

//使用すると・・・
var iteruInst = new Iteru();
iteruInst.hand(); //表示：Iteruのhandが呼び出された

var koIteruInst = new KoIteru();
koIteruInst.hand(); //表示：KoIteruのhandが呼び出された
</pre>
<p>というように、Iteruのhandを呼び出せばIteruのhand処理を実行し、<br />
KoIteruを呼び出せば、Iteruのhandを修正した処理、<br />
KoIteruのhand処理が実行される。</p>
<p>なにやら継承からレベルが何段階か上がってきて、<br />
わかりにくくなってきた。<br />
続きはまた明日。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/596.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/596.html" />
	</item>
		<item>
		<title>継承1（extends）</title>
		<link>http://oneday.ter.jp/actionscript3/563.html</link>
		<comments>http://oneday.ter.jp/actionscript3/563.html#comments</comments>
		<pubDate>Fri, 31 Jul 2009 23:05:38 +0000</pubDate>
		<dc:creator>イテル</dc:creator>
				<category><![CDATA[ActionScript3]]></category>
		<category><![CDATA[as3勉強]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[継承]]></category>
		<category><![CDATA[関数]]></category>

		<guid isPermaLink="false">http://oneday.ter.jp/?p=563</guid>
		<description><![CDATA[
本日は、「継承」を学習する。
意味を理解する
継承はオブジェクト指向のプログラムには欠かすことのできないものらしい。
あるクラスが、別のクラスの変数とメソッド定義を借りる（または受け継ぐ）という、
2つ以上のクラスでの [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://oneday.ter.jp/wp-content/uploads/2009/08/090705-one31-700x200.jpg" alt="090705-one31" title="090705-one31" width="700" height="200" class="alignnone size-thumbnail wp-image-592" /></p>
<p>本日は、「継承」を学習する。</p>
<h3>意味を理解する</h3>
<p>継承はオブジェクト指向のプログラムには欠かすことのできないものらしい。<br />
あるクラスが、別のクラスの変数とメソッド定義を借りる（または受け継ぐ）という、<br />
2つ以上のクラスでの形式的名関係性のことを言うらしい。</p>
<p>噛み砕くと、クラスを別のクラスで使えるようにすることらしい。</p>
<p>参考書には、継承させることで継承されたクラスは元のクラスとある点では<br />
そっくりにしながら、他にはないそれ自体の機能を追加することが可能に<br />
なると書いてあった。</p>
<p>「北斗神拳を継承したケン○ロウが、北斗神拳も使いつつ、<br />
それ以外の独自の技を編み出して使えるようになった。」</p>
<p>と同じ意味なのだろうか・・・。<br />
たぶんそうに違いない。</p>
<h3>継承の入門プログラム</h3>
<p>さっそく、入門編の継承のサンプルを書いてみる。</p>
<pre class="brush: as3;">
public class iteru{
	public var iteruVal = 10;

	public function hand(){
		trace(&quot;メソッドhandが実行&quot;);
	}
</pre>
<p>iteruクラスがあったとする。<br />
これを継承したkoIteruクラスを作る。<br />
koIteruクラスにはさらにfootメソッドを追加してみた。</p>
<pre class="brush: as3;">
public class koIteru extends iteru{
	public function foot(){
		trace(&quot;メソッドfootが実行&quot;);
	}
</pre>
<p>koIteruインスタンスはkoIteruと、<br />
そのスーパークラスiteruの持つすべての<br />
メソッドと変数を使うことができるようになる。</p>
<pre class="brush: as3;">
var koIteru = new koIteru();
//iteruから継承した変数を表示
trace(koIteru.iteruVal);  //表示：10

//iteruで定義されている、継承したメソッドの呼び出し
koIteru.hand(); //→表示：メソッドhandが実行

//koIteruで定義されているメソッドの呼び出し。
koIteru.foot(); //→表示：メソッドfootが実行
</pre>
<p>といった感じでkoIteruがiteruの機能を継承したことがわかるはず。<br />
これと同様に、koIteruをmagoIteruが継承すると、<br />
iteruの機能とkoIteruの機能を有したmagoIteruを作れる。</p>
<p>これは便利。</p>
]]></content:encoded>
			<wfw:commentRss>http://oneday.ter.jp/actionscript3/563.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://oneday.ter.jp/actionscript3/563.html" />
	</item>
	</channel>
</rss>
