close
    what is the difference between virtual function and pure virtual function explain it with an example?

    0  Views: 320 Answers: 1 Posted: 13 years ago

    1 Answer

    They have the same meaning as in C++. A virtual function can be overridden in a derived class. If a object of that derived class is accessed using a handle to its base class, the function call is performed polymorphically - the function called is determined by the type of the object pointed to, not the type of the handle (so the overridden function is called if the object pointed to is of the derived class type).


    A pure virtual function is a member of an "abstract" base class. You cannot create an object of an abstract class. No implementation need be provided for the pure virtual function in the base class but it must be overridden in a derived class if you want to create objects of that type. Pure virtual functions are used to create "interface" classes (not to be confused with the SystemVerilog interface structure). You find examples of these in the OVM TLM classes where they are used to define the set of interface methods required by ports and provided by exports.



    Top contributors in Uncategorized category

     
    ROMOS
    Answers: 18061 / Questions: 154
    Karma: 1102K
     
    Colleen
    Answers: 47269 / Questions: 115
    Karma: 953K
     
    country bumpkin
    Answers: 11322 / Questions: 160
    Karma: 838K
     
    Benthere
    Answers: 2392 / Questions: 30
    Karma: 760K
    > Top contributors chart

    Unanswered Questions

    SV388
    Answers: 0 Views: 4 Rating: 0
    Mộ Đá Trường Thành
    Answers: 0 Views: 9 Rating: 0
    az888vnnet1
    Answers: 0 Views: 11 Rating: 0
    bitart
    Answers: 0 Views: 11 Rating: 0
    > More questions...
    498736
    questions
    735042
    answers
    835433
    users