why do we need to call explicitly call destructor if delete operator will delete the assigned memory and any way delete is going to call destructor then ???
Hey, my code is similar to your code but i am getting destructor printed three times. Here is my code #include using namespace std; class Base{ int *x; public: Base(){cout
It it because you are creating 2 different objects i.e. b and b1. Compiler will call the distructuctor for b, b1 and ofcourse your explicit call of distructor. Hope i have solved ur doubt.
My learning comes from stack overflow website. I used to give answers for the questions and read others answer. As you know there is no direct source of learning so deeply.
This is correct but Consider a situation like that in this video destructor doesn't delete (or free) the memory pointed by the pointer so when the destructor is called the pointer is deleted but the memory to which it is pointing to still remains there (because that memory is not the part of the object.). Now you can't access that memory, which results in the memory leak. This is why destructors are needed.
That is called initializer list, where we initialize the data members not assigned the values to data members..if you are aware of const data member then you can relate it very well.
thanks for the video sir
Most welcome
Hello Sir
Could you please provide the link for Pointer Data Members In C++
Sir please upload videos for Standard template library
Suyash, coming soon!!
why do we need to call explicitly call destructor if delete operator will delete the assigned memory and any way delete is going to call destructor then ???
There is something called placement new there we need to call destructor explicitly. I have video for that please check.
thanks sir
Your videos are helpful , thanks :-)
Thanks Khushi...
You are good thnks
Thank you too
Hey, my code is similar to your code but i am getting destructor printed three times. Here is my code
#include
using namespace std;
class Base{
int *x;
public:
Base(){cout
It it because you are creating 2 different objects i.e. b and b1. Compiler will call the distructuctor for b, b1 and ofcourse your explicit call of distructor.
Hope i have solved ur doubt.
Hello sir, could you please share the pointer data member link, I am not able to find it.
so the compiler defined Destructor will not delete the memory allocated by new operator?
Exactly!!
That is the reason we give our own Destructor.
Sir do you use bracket editor.
No.. i use Sublime text editor 3.
What Could be best book as You learn from you c++ , as You clear concept.
My learning comes from stack overflow website. I used to give answers for the questions and read others answer. As you know there is no direct source of learning so deeply.
sir i didnt find the video-> Pointer Data Members In C++
Gunjan, I have not created it yet, can expect soon. :)
ok
whats the meaning of adding : after declaring the parameters of a function
same question
@@sayantansinharay9161 same
@@sayantansinharay9161 got it watch initializer list
thanks man.
You are welcome
Destrcutor will destroy all the objects and data members which is created for Class if my understanfing is correct. isn't it?
Yes
This is correct but
Consider a situation like that in this video destructor doesn't delete (or free) the memory pointed by the pointer so when the destructor is called the pointer is deleted but the memory to which it is pointing to still remains there (because that memory is not the part of the object.).
Now you can't access that memory, which results in the memory leak. This is why destructors are needed.
@@UvUtkarsh mean it clears the memory address
@@khalidtech7770 Yes, dangling pointer would be there.
Sir in the parameterized constructor , what does " x{a} { } " mean . Have you mentioned this syntax in any of u r videos ??
That is called initializer list, where we initialize the data members not assigned the values to data members..if you are aware of const data member then you can relate it very well.
Holy fk nice
thanks man..
that annoying sound of clicking :D
Sorry now i have cleared almost all the issues from my recording setup. :D