Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  polymorphism
Language: C/C++
Code:
#include "stdafx.h"
#include <iostream>


class Base
{
public:
     void foo() {cout<<"Base foo";}
virtual void goo() {cout<<"base goo";}
};
class Derived : public Base
{
public:
     void foo() {cout<<"derived foo";}
virtual void goo() {cout<<"derived goo";}
};

int main()
{
Derived b; Base *a = &b;
b.foo(); b.goo;
pa->foo(); pa->goo();
return 0;
}
          
          
          
          
          
Comments: