answersLogoWhite

0


Best Answer

Virtual Functions and Pure Virtual Functions are relevant in the context of class inheritance.

Unlike Virtual Functions, Pure Virtual Functions do not require a body. This implies that when a base class defining such a function is inherited, the derived class must implement that function. Furthermore, the base class becomes abstract; meaning you cannot create an instance of the base class even if a body is implemented for the function. You are expected to derive from abstract classes; only the derived classes that implement all the inherited Pure Virtual functions can be instantiated.

Here are some examples of Virtual and Pure Virtual function signatures:

- Virtual Function: E.g. virtual void myFunction();

- Pure Virtual Function: E.g. virtual void myFunction() = 0;

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

In C#, a virtual function (defined in a base class) may be overridden by its derived class(es)

a virtual function provides a default implementation, the override is to change the behavior. It is not the same as "modifying the existing codes". The default one co-exist with the overrides, and may be called/invoked still!!

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

An overloaded function is any function that has two or more versions with different signatures but with the exact same name within the same namespace.

A virtual function is any class method that is declared virtual and is therefore expected to be overridden by derived classes.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the difference between virtual function and function overriding?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Can you have inline virtual functions in a class?

No, inlining is done at compile time whereas virtual functions are resolved at run time(late binding). So, virtual functions can't be inlined. Both properties are orthogonal.Inlining is a mere suggestion the compiler may ignore it if it is declared with virtual function.


What is the Difference between virtual methods and non virtual methods in c sharp?

A function is a method that returns a value other than void. Methods includes functions, subroutines, constructors, destructors, and properties.


A pure virtual function is a virtual function that has?

A pure-virtual function is a function that must be overridden in derived classes. You simply add "=0" to the end of the function declaration. class AbstractClass { public: virtual void DoSomething()=0; // Pure-virtual. };


What is the difference between friend function and inheritance in c plus plus?

There is no such thing. When declaring a friend function only the explicitly-scoped friend is granted private access. The friend function may well be declared virtual within its own class but none of its overrides are granted access unless they are explicitly granted access.


Difference between Method overloading and method overriding in C plus plus?

Yes. Any base class method that is declared virtual can be overridden by a derived class. Overriding a method that is not declared virtual can still be called, but will not be called polymorphically. That is, if you call the base class method, the base class method will execute, not the override. To call a non-virtual override you must call it explicitly.

Related questions

Can you have inline virtual functions in a class?

No, inlining is done at compile time whereas virtual functions are resolved at run time(late binding). So, virtual functions can't be inlined. Both properties are orthogonal.Inlining is a mere suggestion the compiler may ignore it if it is declared with virtual function.


What is the difference between virtual reality and reality?

virtual isnt real.realitysucks


What is the difference between bitween pagefile and virtual memory?

pagefile is the virtual memory


Is there any difference between virtual PC and Microsoft virtual PC?

Nothing.


What is the Difference between virtual methods and non virtual methods in c sharp?

A function is a method that returns a value other than void. Methods includes functions, subroutines, constructors, destructors, and properties.


What is the difference between a real resource and a virtual resource?

a


Difference between overlays in programming and virtual memory?

abcd


What is the difference between virtual and real girl?

A real girl can have a baby. A virtual girl can be deleted from the computer.


A pure virtual function is a virtual function that has?

A pure-virtual function is a function that must be overridden in derived classes. You simply add "=0" to the end of the function declaration. class AbstractClass { public: virtual void DoSomething()=0; // Pure-virtual. };


What is the difference between the real world and the virtual world?

The Virtual World is a place where a man like you will have lots of sex.


What is a difference between a real image and virtual image?

Virtual is not what a human eye can see enot like a reael image


What is virtual function table?

A virtual function table is a table of pointers to functions.