Skip to content

Instantly share code, notes, and snippets.

@torazuka
Created October 2, 2011 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save torazuka/1257374 to your computer and use it in GitHub Desktop.
Save torazuka/1257374 to your computer and use it in GitHub Desktop.
Chapter14_drill_PPPC++
/* 14章ドリル (7) */
#include "../../std_lib_facilities.h"
// ドリル7
class B2 {
public:
virtual void pvf() const =0;
};
class D21 : public B2 {
public:
D21() :s(" "){ }
void pvf() const { cout << "D21::pvf() - " << s << ' '; }
private:
string s;
};
class D22 : public B2 {
public:
D22() :i(0) { }
void pvf() const { cout << "D22::pvf() " << i << ' '; }
private:
int i;
};
void f(const B2& b2)
{
b2.pvf();
}
int main()
{
// ドリル7
D21 d21;
D22 d22;
f(d21);
f(d22);
keep_window_open();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment