[ create a new paste ] login | about

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

C++, pasted on Aug 12:
#include <iostream>
using namespace std;

class Base1 { virtual void dummy() {} };
class Base2 { virtual void dumy() {} };
class Derived: virtual public Base1, public Base2
{ int a; };

class sysCommandExecutor : public Base2
{
public:
int b;
Base1 *ptr;
void func(void);
};

void sysCommandExecutor::func(void)
{
  Derived *d;
  d = dynamic_cast<Derived *>(ptr);
  if (d == NULL)
  std::cout << "This is NULL" << std::endl;
  else
  {
  // Call a function of Derived class
  }
}

int main () {

   sysCommandExecutor * sys =  new sysCommandExecutor;
   sys->ptr=new Derived;
   sys->func();
   return 0;
   
}  


Output:
No errors or program output.


Create a new paste based on this one


Comments: