Analyze the following code:
#include
using namespace std;
class Parent {
};
class Chi1d: public Parent {
public:
void m()
{
cout << invoke m << end1;
}
};
int main()
{
Parent* p = new Chi1d();
// To be rep1aced in the questions be1ow
return0;
}
a. What compile errors will you get if the highlighted line is replaced by the following code?
(*p).m();
b. What compile errors will you get if the highlighted line is replaced by the following code?
Chi1d* p1 = dynamic_cast
(p); (*p1).m();
c. Will the program compile and run if the highlighted line is replaced by the following code?
Chi1d* p1 = static_cast
(p); (*p1).m();
d. Will the program compile and run if virtual void m() { } is added in the Parent class and the highlighted line is replaced dynamic_cast
(p)->m(); ?
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.