method-overloading

    0熱度

    1回答

    我對C#和OOP相當陌生,而且我有一個關於繼承的問題。 說我有: public abstract class Command { protected Command() { } public abstract string Execute(); public abstract string Execute(object o); } pu

    18熱度

    2回答

    public class Program { private static <Program> void foo(Program x){ System.out.println(x+"-->1"); } private static void foo(final int i){ System.out.println(i+"-->2");

    1熱度

    1回答

    我正在學習VB.NET和C# 我在VB中有以下代碼,我在C#中轉換。代碼有一個Form,一個基類Vehicle和一個派生類Car。在VB中,基類Vehicle作爲4個屬性聲明,只有一行沒有設置&,而在C#中,我首先必須聲明變量,然後設置&的4個屬性獲取方法(和很多行)。這是正確的方式,還是有一個像VB一樣簡單的方法? VB.NET Public Class Form1 Private S

    0熱度

    1回答

    我有一個程序,僅僅完美的作品,但編譯器仍然輸出這個惱人的警告代碼: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: 我的程序的simplyfied版本

    0熱度

    1回答

    這是一個被問了很多次的問題,但沒有一個答案似乎適用於此。 我有以下PageBase類: <?php class PageBase { public $templatefile = '404'; function Before() {} function After() {} function Display() { $sm

    1熱度

    2回答

    額外的參數考慮以下情況: class Factory { private $x = 1; private $y = 2; private $z = 3; public function create(string $instance) { return new $instance($this->x, $this->y, $this->z);

    0熱度

    1回答

    我有像編譯好的java代碼。 import org.jaitools.numeric.Range; Range<Integer> r1 = Range.create(1, true, 4, true); 轉換爲斯卡拉像 val r1: org.jaitools.numeric.Range[Integer] = org.jaitools.numeric.Range.create(1, true

    -1熱度

    4回答

    當我寫這個代碼我收到錯誤 public class MethodOverloading { void m(short i) { System.out.println("SHort"); } public static void main(String[] args) { MethodOverloading ml=new MethodOverloading(); ml.m(1

    -1熱度

    1回答

    我正在探索Visitor模式,下面是代碼。請注意,我已經知道如何解決這個問題了 - 使用虛擬方法並用各種過載擴展Visitor界面。我想更好地理解c#中的類型和重載分辨率。 在測試方法中,當調用Accept方法時,它始終使用參數類型「Element」而不是BinaryOperator調用Visit方法。根據關於SO的其他類似問題的答案,這是因爲在編譯時解析了超載方法&對象類型。 鏈接: why-i

    1熱度

    1回答

    我有這個重載函數: CString TestFunction(CString s, int number, int optPar1 = 123, int optPar2 = 456) //... CString TestFunction(int index, CString s, int numbers[], int optPar1 = 123, int optPar2 = 456) //...