類別 'class' 的方法 'method' 定義不支援的預設參數 'parameter'
備註
編譯程式偵測到具有預設值的一或多個參數的方法。 叫用 方法時,將會忽略參數的預設值。。明確指定這些參數的值。 如果您未明確指定這些參數的值,則C++編譯程式會產生錯誤。
Example
假設使用 Visual Basic 建立的下列.dll,其允許方法自變數上的預設參數:
' C4564.vb
' compile with: vbc /t:library C4564.vb
Public class TestClass
Public Sub MyMethod (a as Integer, _
Optional c as Integer=1)
End Sub
End class
下列 C++ 範例使用使用 Visual Basic 建立的 .dll,
// C4564.cpp
// compile with: /clr /W4 /WX
#using <C4564.dll>
int main() {
TestClass ^ myx = gcnew TestClass(); // C4564
myx->MyMethod(9);
// try the following line instead, to avoid an error
// myx->MyMethod(9, 1);
}