PART I
C h a p t e r 8 :
A C l o s e r L o o k a t M e t h o d s a n d C l a s s e s
191
PART IPART I
Overload2 ob = new Overload2();
int i = 10;
double d = 10.1;
byte b = 99;
short s = 10;
float f = 11.5F;
ob.MyMeth(i); // calls ob.MyMeth(int)
ob.MyMeth(d); // calls ob.MyMeth(double)
ob.MyMeth(b); // calls ob.MyMeth(int) -- type conversion
ob.MyMeth(s); // calls ob.MyMeth(int) -- type conversion
ob.MyMeth(f); // calls ob.MyMeth(double) -- type conversion
}
}
The output from the program is shown here:
Inside MyMeth(int): 10
Inside MyMeth(double): 10.1
Inside MyMeth(int): 99
Inside MyMeth(int): 10
Inside MyMeth(double): 11.5
In this example, only two versions of
Do'stlaringiz bilan baham: |