Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Overloading

 
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 ]
 
Ranch Hand
Posts: 2410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not getting a compile-time error on the first code.
 
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.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic