我不明白当您使用构造函数 Rational() 创建 Rational 对象时会发生什么。我的书说它将创建一个值为 0 但内部存储为 0/1 的 Rational 对象。this(0) 如何存储为 0/1?num 和 den 的实例变量的默认值不是 0 吗?
public class Rational{
public Rational(){
this(0);
}
public Rational(int n){
this(n,1);
}
public Rational(int x, int y){
num = x;
den = y;
}
private int num;
private int den;
}