I already fill the blanks lines(line1, line2 line3) but I am not getting any output.
Note - only need to edit those three lines
Code -
#include <iostream>
#include <cstring>
using namespace std;
class Base
{
protected:
string s;
public:
Base(string c) : s(c) {}
virtual ~Base() {} // line 1
virtual string fun(string a) = 0; // line 2
};
class Derived : public Base
{
public:
Derived(string c) : Base(c) {}
~Derived();
string fun(string x)
{
return s + x;
}
};
class Wrapper
{
public:
void fun(string a, string b)
{
Base *t = (Base *) &a; // LINE-3
string i = t->fun(b);
cout << i << " ";
delete t;
}
};
Derived::~Derived() { cout << s << " "; }
int main()
{
string i, j;
cin >> i >> j;
Wrapper w;
w.fun(i, j);
return 0;
}
More details and input/outputs -
input - o k
expected output - ok o
input - c ++
expected output - c++ c
Details about these Q - I don't know what to write here so please forgive for not writing it.