alex lotel

Ranch Hand
+ Follow
since Feb 01, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by alex lotel




why the outpout is false??
y1 will use the method f from B .because B is the son of A and they both have f
further more the father doesnt have a method f wich recieves B type variable
y2.num=10
y1.num=10
and they are equla
11 years ago


y1 is a mixed varible.
to what fuction should i put y1
a function f that inputs A variable or B variable
?
11 years ago
I understood that we cant a non specific variable to a specific like e=c
but we can cheat thec complier because one extends the other directly?

but what if E extends G
and G extends C

i.e we have one class in the middle
will it still be cheated

my question is in general in what cases we can cheat the compiler

??

and i got problems with:


i thought it would use the b method of B,but it used the b method of G

why??


regarding this line:

why the compiler said that we cannot cast F into G
??
12 years ago
ok but previosly
when we did
e=(E)c
we cheated the compiler it allowed us to do it,but we failed on the running time.
so i understand that the ruke is that we cast cast only from classes that there is a direct inheritance relationship.

regarding:

over riding is when we use some other function instead of the function in class B.
in this line we dont override thestatic fubction in class B we try to use it.
where am i wrong?

and i know that G inherits F which inherits B
?
12 years ago
regarding

D and E classes both inherit class C

still cant see why casting wont cheat the compiler
?




regarding:
over riding is when we use some other function instead of the function in class B.
in this line we dont override thestatic fubction in class B we try to use it.
where am i wrong?

and i know that G inherits F which inherits B
12 years ago
this is the tree,how does it helps me seeing why i dont get the proper responce/?

12 years ago
the first loop switches the i'th member backoward like in insertion sort till it gets a valuse smalle then maxvalue
but it switch always with a[i-2]
so i cant see the purpose


the second loop does a similar thing
but i cant see what is the general purpose
??


12 years ago
regarding

I thought it would cheat the compiler becuase of the casting
and it would fail on the running time.


but the compiler said incompatible types.

why??

also on this line

i thought it would use the b method of B,but it used the b method of G

why??


regarding this line:

why the compiler said that we cannot cast F into G
??
12 years ago
if we add


to the class bellow will it work or will get a bug?
if it will give a bug then it will be on the compiler problem or running time problem?






12 years ago
i am not native english speaker so please be considerate

So to summerise my cases:



regarding x.eat():
if there no eat method in pie 'but there is one in food then it will call the method from food because it inherits food class.
if there is eat in pie then it will call the method from pie.

regarding y.eat():
if there is no eat method in food then it wont compile because y is of type food.
if there is no eat in pie but there is one in food then it will call the method eat in food.

correct?

12 years ago
so "y" can use only the methods in pie which are present in food
correct?
12 years ago
so if in both classes i have a (non static) mathod "eat"
and will do

x will call the method from pie
and y will call the method from pie.

question regarding case 1:
if "food" doesnt have a method "eat"

what will happen?

and on the opposite case 2:
if "food" has a method "eat" but pie doesnt ave one

what will happen?

and the same as case 2

what will happen?
12 years ago
if i have food class and pie class which inherits food
regarding the accsess level

i have


i know that both are reference variable of pie,
but x is of type pie and y is of type food.
what is the difference between the two regarding method accsess in both classes
?
12 years ago



and there is this code ,where min return the minimum of a,b


function "f" returns the shortest what to a leaf.

i dont know what function "what" does
?
12 years ago
there is class NODE:


And there is this code max (int a, int b) returns the biggest number amongst a,b , max (int a, int b, int c) returns the biggest number amongst a,b,c



what does function what does if "t" is the root of a binary tree
?


how i tried to solve it:
i see that function "f" calculates that longest path to a leaf
but i cant see what function "what" does?
12 years ago