面向对象程序设计-C++_课时28静态对象_课时29静态成员

Posted 邓戈麟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了面向对象程序设计-C++_课时28静态对象_课时29静态成员相关的知识,希望对你有一定的参考价值。

 

Static in C++

Two basic meanings

Static Storage

--allocated once at a fixed address

Visibility of a name

--internal linkage

Don‘t use static except inside functions and classes.

 

Uses of "static" in C++

Static free functions----deprecated弃用

Static globle variables----deprecated弃用

Static local variables----Persistent storage持久存储

Static member variables----Shared by all instances所有对象共享

Static member functions----Shared by all instances, can only access static member variables所有对象共享,只能访问静态变量或静态函数

 

Static inside functions

Value is remembered for entire program

Initialization occurs only once

以上是关于面向对象程序设计-C++_课时28静态对象_课时29静态成员的主要内容,如果未能解决你的问题,请参考以下文章