In short, "virtual function" is the C++ term for a polymorphic function/method. In Java, all (non-static) methods are polymorphic - there is no way to declare a "non-virtual function". [ July 11, 2002: Message edited by: Ilja Preuss ]
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Declaring a function "private" also makes it effectively non-virtual.
"I'm not back." - Bill Harding, Twister
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Frank Carver: Sorry Ilja, but declaring a method as "final" in Java is roughly equivalent to a non-virtual in C++. It's a horrible thing to do though.
Yeah, *very* roughly... Mhh, can you declare a method as non-virtual which overrides a virtual one in C++? What would happen?
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Jim Yingst: Declaring a function "private" also makes it effectively non-virtual.
Hi sandeep, The virtual modifier signals the compiler that this member function is expected to be overridden by a derived class. See the sample code below:
The member function invoked depends on the runtime type of the object being referenced by the pointer. Note this polymorphic behavior only applies to pointers and references.
sandeep kokane
Greenhorn
Joined: Nov 29, 2000
Posts: 19
posted
0
Thanks A Lot all of u. Actually i know that there is not "virtual" keyword in the JAVA. But the question about is asked me in the JAVA technical interview. So i was confuse that time. Thanks A lot again .