class A {
public:
void show() {
cout << "Class A Show"<<'\n';
}
};
class C : public A {
public:
void show() {
cout << "Class C Show" << '\n';
}
};
int main() //first int main()
{
C* a = new C; //line 1
a->show(); //line 2
a = new A(); //line 3
a->show(); //line 4
}
int main() //2nd int main()
{
A* a = new C; //line 1
a->show(); //line 2
a = new A(); //line 3
a->show(); //line 4
}
Question :
Output of each line in both int main () when rum separately
Error A value of Type "A*" cannot be assigned to a value of Type "C*"
I came across a interview question where the panel asked the outputs of the mentioned 2 int mains() and asked if it produces an error than how can we omit that error. I tried this code on compiler and the error came on line 3 of First int main() while 2nd int main() ran without an error