+ Post New Thread
Results 1 to 4 of 4

Thread: What is virtual function on C++?

  1. #1
    Senior Member shreeharisg's Avatar
    Join Date
    Feb 2014
    Posts
    103
    Post Thanks / Like

    Exclamation What is virtual function on C++?



    What is virtual function on C++? Give any example of it.

  2. #2
    Junior Member michral's Avatar
    Join Date
    May 2017
    Posts
    8
    Post Thanks / Like


    Is this useful / helpfull? Yes | No
    In languages such as C++, a virtual function or virtual method is an inheritable and overridable function or method for which dynamic dispatch is facilitated. This concept is an important part of the polymorphic portion of object-oriented programming.
    virtual methods are declared by prepending the virtual keyword to the function's declaration in the base class. This modifier is inherited by all implementations of that method in derived classes, meaning that they can continue to over-ride each other and be late-bound. And even if methods owned by the base class call the virtual method, they will instead be calling the derived method.
    For example, a base class Animal could have a virtual function eat. Subclass Llama would implement eat() differently than subclass Wolf, but one can invoke eat() on any class instance referred to as Animal, and get the eat() behavior of the specific subclass.

  3. #3
    Junior Member Server9host's Avatar
    Join Date
    May 2017
    Posts
    29
    Post Thanks / Like


    Is this useful / helpfull? Yes | No
    Virtual functions permit a program to decision strategies that do not essentially even exist at the instant the code is compiled.In object-oriented programming, in languages like C++, a virtual function is an Associate avoidable technique that dynamic dispatch is accelerated.

  4. #4
    Junior Member jackwilliam's Avatar
    Join Date
    Jul 2017
    Location
    india
    Posts
    7
    Post Thanks / Like


    Is this useful / helpfull? Yes | No
    A virtual function makes its class a polymorphic base class. Derived classes ... What is the difference between a virtual function and pure virtual function in C++?.

+ Post New Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam