ページ 11

オーバーロードが不可能

Posted: 2006年9月10日(日) 17:40
by Sinryow
現在TCPクライアントのクラスを作成しているのですが

クラス定義部

コード: 全て選択

Class TCPClient

   :
   :

Public
	' ========== サーバーをセットする ==========

	' アドレスを1つずつ指定する場合	
	Function SetServer(nAddr1 As Byte, nAddr2 As Byte, nAddr3 As Byte, nAddr4 As Byte) As Long
		Dim arrAddr[ELM(4)] = [nAddr1, nAddr2, nAddr3, nAddr4] As Byte
		server = This.SetServer(arrAddr, 4)
		SetServer = (server <> NULL)
	End Function

	' ホスト名で指定する場合
	Function SetServer(strHost As *Byte) As Long
		server = gethostbyname(strHost)
		SetServer = (server <> NULL)
	End Function

	' ========== ポートをセットする ==========

	' ポート番号で指定する場合
	Function SetPort(nPort As Word)(strProtocol As *Byte) As Long
		port = getservbyport(htons(nPort) As Long, strProtocol)
		SetPort = (port <> NULL)
	End Function

	' サービス名で指定する場合(例:"http")
	Function SetPort(strService As *Byte)(strProtocol As *Byte) As Long
		port = getservbyname(strService, strProtocol)
		SetPort = (port <> NULL)
	End Function

   :
   :

End Class
実行部

コード: 全て選択

Dim tcpc As TCPClient

tcpc.SetServer("www.activebasic.com")
tcpc.SetPort("http")
このコードを実行すると、SetServerの方は問題ないのですが、SetPortの方で「オーバーロードを解決できません」というコンパイルエラーが出ます。
AB4.21、4.24、5.00β4のいずれも同様です。

Posted: 2006年9月12日(火) 11:14
by 山本
申し訳ありませんが、引数省略昨日は一般的に利用するには仕様が未熟です。今後改正される可能性がありますので、なるべくご利用を控えられるよう、お願い致します。

Posted: 2006年9月16日(土) 21:00
by Sinryow
省略可能な引数を使ったのが理由だったのですか・・・了解です。
オーバーロードで代替します。