Will the below code cause memory leak in c++

前端 未结 7 1917
醉话见心
醉话见心 2020-12-05 08:13
class someclass {};

class base
{
    int a;
    int *pint;
    someclass objsomeclass;
    someclass* psomeclass;
public:
    base()
    {
        objsomeclass = so         


        
7条回答
  •  忘掉有多难
    2020-12-05 08:41

    If you throw in a constructor, you should clean up everything that came before the call to throw. If you are using inheritance or throwing in a destructor, you really shouldn't be. The behaviour is odd (don't have my standard handy, but it might be undefined?).

提交回复
热议问题