Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overloading

 
venkatesh pendharkar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,I mam trying to compile this code &

i dont understand why its giving a comile time saying reference to met() is ambiguous.Doesnt compiler understand that 12 is in int so e.met(12) should call met(int a) in superclass

Also the same code works fine if we overload met() in class E

I dont understand how cum this code works now when methods are overloaded. Somebody please explain.


(added tags)
[ November 27, 2006: Message edited by: Barry Gaunt ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not getting a compile-time error on the first code.
 
Satish Kota
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by venkatesh pendharkar:

i dont understand why its giving a comile time saying reference to met() is ambiguous.

Venkatesh,
The 1st code compiles fine here. I dont get any error. I get an output of 144 for both the cases.
 
venkatesh pendharkar
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how is this possible??i am trying the same code on jdk 1.4 & its giving me reference to met() is ambigous error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic