As mentioned in this answer simply calling the destructor for the second time is already undefined behavior 12.4/14(3.8).
I am confused about how to use destructors when I have a std::vector of my class. So if I create a simple class as follows:
I have a variable or array, which I no longer needed. How to destroy them? Sorry for noob-开发者_开发百科question.You don\'t. Just let the reference go out of scope and it\'ll be automatically garbage
How does one suppress the automatic initialization and destruction of a type?While it is wonderful that T buffer[100] automatically initializes all the elements of buffer, and destroys them when they
Let\'s say I have the following code: struct mytype { ~mytype() { /* do something like call Mix_CloseAudio etc */ }
I am having a problem with delete and destructor (I am sure I am making a stupid mistake here, but haven\'t been able to figure it out as of yet).
[a follow up to this question] class A { public: A(){cout<<\"A Construction\"<<endl;} A(A const& a){cout<<\"A Copy Construction\"<<endl;}
Say for example i have the following code (pure example): class a { int * p; public: a() { p = new int; 开发者_StackOverflow社区}
Apologies if the question sounds silly, I was following experts in SO and trying some examples myself, and this is one of them. I did try the search option but didn\'t find an answer for this kind.
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by e开发者_Pytho