[ create a new paste ] login | about

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

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

class Base{
  private:
   int a;
  public:
   Base(int value):a(value){ 
  }

  virtual void print(){
   std::cout<<"In base "<<a<<std::endl;
  }
};

class Derived:public Base{
  private:
   int b;
  public:
   Derived(int valD, int valB):b(valD):Base(valB){ 
  }

  virtual void print(){
   std::cout<<"In Derived "<<b<<std::endl;
  }
};

int main(){
 Base* b = new Base(5);
 Derived* d = new Derived(10,11);
 b->print();
 d->print();
 return 0;
}


Output:
1
2
3
t.cpp: In constructor 'Derived::Derived(int, int)':
Line 19: error: no matching function for call to 'Base::Base()'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: