Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ interview question involving class pointers

Tags:

c++

Lets say there is a base class pointer which is pointing to a base class object:

baseclass *bptr;
bptr= new baseclass;

now if i do

bptr= new derived;

what is the problem here?

like image 267
Vijay Avatar asked Jun 10 '10 07:06

Vijay


1 Answers

The obvious answer is that you're leaking the original base class object.

like image 113
Tetrad Avatar answered Sep 22 '22 13:09

Tetrad