当前位置:网站首页>Static keyword and its application

Static keyword and its application

2022-04-23 22:04:00 Scarcity risk humility

1、 Used in this procedure page , Variables with the same name on different pages will not conflict ;
2、 Variable life cycle accompanies the whole program life cycle ;
1、 Static data members are also called class variables , Common data members are also called instance variables ; Static data members are each class All have one , The common data member is each instance There is one ;
2、 Static member functions : Used to modify class Member function of
1. Static members can access each other , Including static member functions, accessing static data members and accessing static member functions .
2. Non static member functions can arbitrarily access static member functions and static data members .
3. Static member functions cannot access non static member functions and non static data members .
4. Call static member function , You can use member access operators (.) and (->) Calling static member functions for an object of a class or a pointer to an object of a class , You can also use the class name :: Function name call ( Because he belongs to class , It's normal to call with a class name )

版权声明
本文为[Scarcity risk humility]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/113/202204232201249957.html