If I delete a class, are its member variables automatically deleted?

前端 未结 8 600
故里飘歌
故里飘歌 2020-12-13 06:28

I have been researching, and nothing relevant has come up, so I came here.

I am trying to avoid memory leaks, so I am wondering:

Say I have class MyCla

8条回答
  •  长情又很酷
    2020-12-13 07:15

    Your three variables were not allocated with new so there would be no need to delete them at all.

    They would be destructed when your class is deleted (as they were allocated when your class was newd), but that's not the same as being deleted.

提交回复
热议问题