Something about static Methods in C++ you should know
来源:互联网 发布:图片美化软件 编辑:程序博客网 时间:2024/05/17 04:53
1.
It's not allowed to declare static methods as const.
The non-static versions of the methods can be marked as const.
2.
The static methods are scoped by the name of the class in which they are defined, but are not methods that apply to a specific object.
In C++, you cannot override a static method.
First of all, a method cannot be both static and virtual.
If you have a static method in your subclass with the same name as a static method in your superclass, you actually have two separate methods. These two methods are in no way related.
class SuperStatic
{
public:
static void beStatic()
{
cout << "SuperStatic being static." << endl;
}
};
class SubStatic : public SuperStatic
{
public:
static void beStatic()
{
cout << "SubStatic keepin' it static." << endl;
}
};
SuperStatic::beStatic();
SubStatic::beStatic();
The results:
SuperStatic being static.
SubStatic keepin' it static.
SubStatic mySubStatic;
SuperStatic& ref = mySubStatic;
mySubStatic.beStatic();
ref.beStatic();
The results:
SubStatic keepin' it static.
SuperStatic being static.
- Something about static Methods in C++ you should know
- Something you should know in C++
- Should know something about OS
- Something what you should know (floating point)
- What you should know about salary plateau
- You should know this about google(plus)
- 7 Python Libraries you should know about
- What You Should Know About Floats
- 5 XSS Exploits You Should Know About
- Something you need to know about INITIALIZATION LISTS in Constructor of C++
- FW: Everything you need to know about pointers in C
- Something you need to know about Objective-C and iOS programming: for experienced programmers
- What you should know about Stored Procedure Universe in BI 4.0 ?
- Top 2 things you should know about the Global Assembly Cache (GAC) in .NET 4.0
- Task cancellation in C# and things you should know about it
- something we should know
- Modules you should know in Python Libray
- 10 things you should know about every Linux installation(ZT)
- Html+JS+HTMLdom+Json+JQuery 常用基础知识点汇总
- RSA算法优化
- linux下验证码不显示的问题
- Java Web连接各种数据库方式汇总
- 【高手分享:巧设提高U盘数据传输速度】
- Something about static Methods in C++ you should know
- MySQL中UNION和UNION ALL的使用
- Linux中select poll和epoll的区别
- cp Linux命令详解
- 10个经典的Android开源应用项目
- HDU 2089 不要62(数位DP入门)
- [小说]魔王冢(2)意乱情迷
- 博士生传给硕士生的经验!
- vi 命令详解