ab.com コミュニティ
https://www.activebasic.com/forum/

オーバーロードが不可能
https://www.activebasic.com/forum/viewtopic.php?t=1529
ページ 11

作成者:  Sinryow [ 2006年9月10日(日) 17:40 ]
記事の件名:  オーバーロードが不可能

現在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のいずれも同様です。

作成者:  山本 [ 2006年9月12日(火) 11:14 ]
記事の件名: 

申し訳ありませんが、引数省略昨日は一般的に利用するには仕様が未熟です。今後改正される可能性がありますので、なるべくご利用を控えられるよう、お願い致します。

作成者:  Sinryow [ 2006年9月16日(土) 21:00 ]
記事の件名: 

省略可能な引数を使ったのが理由だったのですか・・・了解です。
オーバーロードで代替します。

ページ 11 全ての表示時間は UTC+09:00 です
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/