Child cObj = new Parent()
Wahts the output ?

Answer Posted / donga bangarraju

sorry for the earlier post, this output is giving error like
initializing cannot convert to Paretn* to Child*, if u want
correct this code write like this, this is downcasting or
using RTTI mechanism in C++;

Parent* p =new Child;
Child* obj= dynamic_cast<Child*>(p);

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of polymorphism?

681


Why is polymorphism needed?

600


#include #include #include #include void insert(char *items, int count); int main(void) { char s[255]; printf("Enter a string:"); gets(s); insert(s, strlen(s)); printf("The sorted string is: %s.\n", s); getch(); return 0; } void insert(char *items, int count) { register int a, b; char t; for(a=1; a < count; ++a) { t = items[a]; for(b=a-1; (b >= 0) && (t < items[b]); b--) items[b+1] = items[b]; items[b+1] = t; } } design an algorithm for Insertion Sort

2168


what type of question are asked in thoughtworks pair programming round ?

1762


What is inheritance in simple words?

627






Why do we use encapsulation in oops?

522


What are main features of oop?

633


What is overriding vs overloading?

584


Following are the class specifications: class {int a}; class {int b}; Using friend funtion,calculate the max of two objects and display it.

2008


Why multiple inheritance is not allowed?

584


What is destructor example?

597


What is overriding in oop?

550


What is abstraction and encapsulation?

575


What is encapsulation oop?

578


What is debug class?what is trace class? What differences are between them? With examples.

1610