Skip to content

Instantly share code, notes, and snippets.

@alexshires
Created February 6, 2015 12:58
Show Gist options
  • Save alexshires/0cbef200036778d8efe7 to your computer and use it in GitHub Desktop.
Save alexshires/0cbef200036778d8efe7 to your computer and use it in GitHub Desktop.
virtual functions
#include <iostream>
class A {
public:
virtual double f () = 0 ;
double g() { return f() ; }
} ;
class B : public A {
public:
double f() { return 1 ; }
} ;
int main(int argc, char *argv[])
{
B b ;
std::cout << b.g() << std::endl ;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment