作者Taique (阿萨布鲁‧湖澜)
看板java
标题[问题] 关於建构子与继承
时间Mon Sep 11 23:37:12 2006
============================================================
class B extends A{
private int x,y;
B(int x, int y){
this.x=x;this.y=y;}
void printXY(){System.out.print("B: x=" + x + ", y=" + y);}
public static void main(String[] args){
A t = new B(1,2);
t.printXY();}
}
class A{
private int x,y;
A(int x, int y){
this.x=x;this.y=y;}
void printXY(){System.out.print("A: x=" + x + ", y=" + y);}
}
=============================================================
上面的程式码为什麽会产生找不到class A的Constructor的compile error?
不是应该会有 Default Constructor 吗?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 61.225.190.55