Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Base{
- public:
- class iImplement{
- public:
- virtual int func() = 0;
- };
- Base(iImplement *impl): impl(impl) {}
- bool func2(){
- return func() < 5;
- }
- private:
- iImplement *impl;
- int func(){
- return impl->func();
- }
- };
- class Derived: public Base{
- public:
- class DerivedImplement: public iImplement{
- public:
- int func() final {
- // sugoi syori
- return 10;
- }
- };
- Derived(iImplement *impl=new DerivedImplement()): Base(impl) {}
- };
- class TestSuite{
- public:
- class TestImplement: public Base::iImplement{
- public:
- int func_value;
- int func() final {
- // stub
- return func_value;
- }
- };
- TestSuite(): t(new TestImplement), d(t){}
- void run_test(){
- func2_test();
- }
- private:
- TestImplement *t;
- Derived d;
- void func2_test(){
- t->func_value = 10;
- cout << d.func2() << endl;
- t->func_value = 0;
- cout << d.func2() << endl;
- }
- };
- int main(){
- TestSuite test;
- test.run_test();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement