Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
211 views
in Technique[技术] by (71.8m points)

c++ - Do you have to deallocate a const int if you declared it inside a function?

void func()
{
    const int intAge = 24;
}

What happens with intAge after you run func()? Do you have to deallocate it, or does the C++ compiler do this?

question from:https://stackoverflow.com/questions/65941215/do-you-have-to-deallocate-a-const-int-if-you-declared-it-inside-a-function

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The storage of variables with automatic storage duration is deallocated automatically when the variable goes out of scope. This is handled by the language implementation.

In fact, there is no need and no way to manually deallocate memory of any variable. Only dynamic memory can be deallocated manually.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...