The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

RE: Virtual Function

Posted by Kishori Sharan on August 16, 2000 at 2:40 PM

Hi
In C++ virtual function has the following meaning:
"A virtual function is a member function that you expect to be redefined in derived classes. When you refer to a derived class object using a pointer or a reference to the base class, you can call a virtual function for that object and execute the derived class's version of the function."
In java, you don't need to declare a method as virtual. This is the default behaviour. If you don't want a function to be vitual you declare it as final in java. In java if you define a method in descendent with the same signature as in ancestor then it automatically overrides the ancestor method.

Thanx
Kishori




Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us