Howdy, Stranger!

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


What is a local block?

ezrankingsezrankings West Chester, PA, 19380Member Posts: 2

What is a local block in C++?


  • ahmedjebahmedjeb Member Posts: 2

    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:

Sign In or Register to comment.