C++ Programming - OOPS Concepts - Discussion
Discussion Forum : OOPS Concepts - General Questions (Q.No. 3)
3.
Which of the following statements is correct?
Discussion:
41 comments Page 2 of 5.
Souradip said:
1 decade ago
The actual reason is - a derived class has all information about a base class and also some extra bit of information. Now a pointer to a derived class will require more space and that is not sufficient in base class. So the a pointer to a derived class cannot point to it. While on the other hand the reverse is true.
Kaustav said:
1 decade ago
Down casting possible, up casting not possible.
Nambiar Sreeram Ramesh said:
1 decade ago
@Souradip.
I am totally agree with you. Because it is not at all possible that the base class holds the contents of derived class.
I am totally agree with you. Because it is not at all possible that the base class holds the contents of derived class.
Sravani said:
1 decade ago
Base class has capability to create pointer. Derived class is derived from base class only so it is also has access that pointer.
Sneha kuwar said:
1 decade ago
Because derived class does not have detailed about its based class.
Abhinav said:
1 decade ago
Yeah sure its not necessary to do this but we can assign base class object's address to a derived class pointer by typecasting.
Satya said:
1 decade ago
I agree with @Sneha kuwar because derive class does not have any knowledge about its base class.
Danunjaya said:
1 decade ago
Hi guys. But using static_cast<> we can assign base class pointer to derived class pointer.
Shelvane Baburao said:
1 decade ago
Can you give me example of static_cast<> to assign base class pointer to derived class.
Fayaz said:
1 decade ago
Why option D is not correct?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers