2011-12-15 226 views
3

我想調用2-arg構造函數作爲默認構造函數。 通過這個我的意思是;當調用no-arg構造函數時,它會使用默認值調用 2-arg構造函數。無參數構造函數調用2參數構造函數

public class Foo 
{ 
    int foo1; 
    int foo2; 

    public Foo() 
    { 
    Foo(0, 0); //error   //I also tried this.Foo(0,0); 
    } 
    public Foo(int one, int two) 
    { 
    this.foo1 = one; 
    this.foo2 = two; 
    } 
} 

如何調用第二個構造函數?

+0

這是*幾乎*一個很大的問題(如果它包含的具體問題,「我怎麼叫2號構造?「),但它缺少你描述的部分(也就是我的意思是複製/粘貼)發生錯誤的輸出,無論哪種方式。 – 2011-12-15 19:45:57

回答

相關問題