1363 views|0 replies

6579

Posts

0

Resources
The OP
 

Detailed explanation of all usages of Static keyword [Copy link]

In the past, I was always ambiguous about the meaning of static, and I was reluctant to use it, and I didn't know where to use it. In fact, static is widely used, such as static variables, static members, static functions, etc. If used well, it will elevate the program to a higher level and solve many practical problems, such as the singleton pattern... Moreover, static data members are stored in the static storage area and only stored once, which can save memory. So here I will make a summary based on my current understanding: Usage 1: My understanding of static local variables is that they are somewhat similar to the functions of global variables, but can only be assigned once, that is, after the function is assigned for the first time, the value will be saved. void f() { static int st=10; st++; cout<
Detailed explanation of all usages of Static keyword


This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list