What is a local block?

ezrankingsezrankings West Chester, PA, 19380

What is a local block in C++?


  • A block is an encapsulation of set of code that can be used for different purposes. Functions are local blocks in their module. If a function has if's, try/catch blocks, these are local blocks inside that function.

    Any variables declared there are usable within the block only - once the process exits the block, they are cleared out. You can however use and update variables declared in parental scope and they will stay usable after exiting the block.

    Here's an example: http://en.cppreference.com/w/cpp/language/scope

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion