C++ Programming - OOPS Concepts - Discussion

Discussion Forum : OOPS Concepts - General Questions (Q.No. 3)
3.
Which of the following statements is correct?
Base class pointer cannot point to derived class.
Derived class pointer cannot point to base class.
Pointer to derived class cannot be created.
Pointer to base class cannot be created.
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
41 comments Page 4 of 5.

Pradeep said:   1 decade ago
Whether Virtual Function is available or not, derived class pointer is not required at all. When base class pointer is created, both the members from base and derived can accessible from it.

Deepak Tak said:   1 decade ago
Because its top-down approach.

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.

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.


Post your comments here:

Your comments will be displayed after verification.