Skip to content

Instantly share code, notes, and snippets.

@brianherman
Created October 2, 2014 19:09
Show Gist options
  • Save brianherman/28245fffdcb84f3559bb to your computer and use it in GitHub Desktop.
Save brianherman/28245fffdcb84f3559bb to your computer and use it in GitHub Desktop.
:)
//in file ClassA.cpp
#include <stdio.h>
class ClassA {
public:
virtual void f( void );
};
class ClassB : public ClassA{
public:
void f( int x = 0);
};
void ClassA::f( void )
{
printf("Hello class A");
//implementation is irrelevant
}
void ClassB::f( int x = 0 )
{
printf("Hello Class B");
//implementation is irrelevant
}
int main(int argc, char **argv){
ClassA *instanceOfClassB = new ClassB();
instanceOfClassB->f();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment