Thread: difference between pure virtual class and interface

  1. #1

    difference between pure virtual class and interface

    hi guys,
    what is difference between pure virtual class and interface (with respect to C++ not java).if there is no difference then why is there IUKnown interace ?


  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    An interface is just a contract in the sense that it is guaranteed to be implemented, ie: there will be a spot on the v-table for that member function. A pure virtual class basically the same thing. All Windows Com objects must implement the IUnknown interface.
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
        return std::pow
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;

  3. #3
    Registered User
    Join Date
    Nov 2001
    Pure virtual function is a description of a C++ implementation. An interface is a description of a COM design architecture.


  4. #4

    difference between interface and base virtual class

    hi guys,
    the difference i understand from your point of view is that base virtual class has nothing to do with vtable unlike interface.
    anyone to comment on that is welcomed.


  5. #5
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003

    In C++, there is no concept of the interface. In C++, you have base classes with virtual functions. These virtual functions have entries in the virtual function table, so that polymorphic calls are possible.

    The Component-Object-Model (COM) and its relatives (CORBA, XPCOM, ...) as well as Java define the notion of an interface. An interface is a set of functions that an object promises to support. Interfaces are an abstract concept, the implementation is up to the system.

    In COM and XPCOM the binary representation of an interface "happens" to be the same as of a C++ class that has only pure virtual methods. But any other language with a compiler that can create this binary pattern can create interfaces too (Borland Delphi can do it I think).
    All the buzzt!

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 06-18-2009, 04:58 AM
  2. Platform game gravity problem
    By Akkernight in forum Game Programming
    Replies: 33
    Last Post: 02-22-2009, 01:10 PM
  3. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  4. abstract class
    By xddxogm3 in forum C++ Programming
    Replies: 5
    Last Post: 01-01-2005, 09:08 AM
  5. Exporting Object Hierarchies from a DLL
    By andy668 in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 01:26 PM