i have

why we must initialize .ctors and .dtors?what they have,pointers?pointer to what?
if they not run what happen?for example if we have below variable
//global
int x;
///
what happen when .ctors and .dtors run?
thank very much!
Code: Select all
#include <MyClass.hpp>
int main()
{
MyClass foo();
foo.do();
return 0;
}
Code: Select all
#include <MyClass.hpp>
static MyClass bar();
int main()
{
bar.do();
return 0;
}
If you have static objects of that class type, then yes. (The compiler generates "default" constructors / destructors in this case, which should still be called.)hojjatrakhshani wrote:if my class have no constructor and Destructive then .ctors and .dtors must be initialize?
Now we come to the point where lack of language precision becomes a problem. Are you asking what .ctors (a section in a binary file) does, or what a constructor (an element of object-oriented programming languages) does?indeed what they do(.ctors & .dtors)?
And now we come to the point where I suspect you would be better off asking these questions in a forum primarily aimed at programming beginner questions (like stackoverflow.com). You should know very precisely what "initialization" means, if you want to follow the discussions on this particular board, which is aimed at rather advanced programming topics. Anyway, you shouldn't worry about issues of the runtime yet. (Don't try to run before you can walk.)what means of initialize exactly?