Created
October 2, 2011 11:45
-
-
Save torazuka/1257374 to your computer and use it in GitHub Desktop.
Chapter14_drill_PPPC++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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