below is oonly for fixed source and target. Please looking forward to the all-powerfull converetor.
#include <string>
#include <iostream>
class Target{
public:
virtual void target_request(){ std::cout << "Target request" << std::endl; };
};
class Source{
public:
virtual void source_request(){ std::cout << "Source request " << std::endl; };
};
class Convertor:public Target, private Source{
public:
virtual void target_request(){ this->source_request(); };
};
int main(){
Convertor* c = new Convertor();
c->target_request();
return 0;
}
// class Convertor:public Target{
// public:
// Target* target;
// Convertor( Source *s): source(s){};
// virtual void target_request(){ return source->source_request(); };
// private:
// Source* source;
// };
// int main(){
// Source* s = new Source();
// Target* c = new Convertor(s);
// c->target_request();
// return 0;
// }
|