[ create a new paste ] login | about

Link: http://codepad.org/z7rXpCeK    [ raw code | output | fork ]

C++, pasted on Jan 23:
#include <iostream>

using namespace std;

class base
{
   public:
      virtual int func()
      {
         cout << "vfunc in base class\n";
         return 0;
      }
};

class derived: public base
{
   public:
      double func()
      {
         cout << "vfunc in derived class\n";
         return 0;
      }
};

int main()
{
   base *bptr = new derived;
   bptr->func();

   return 0;
}


Output:
1
2
Line 18: error: conflicting return type specified for 'virtual double derived::func()'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: