c++ 静态
来源:互联网 发布:网络语666是什么意思 编辑:程序博客网 时间:2024/06/08 08:32
// ConsoleApplication6.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>using namespace std;class Point{public: void init() { cout << "init" << endl; } static void output() //类的静态方法 { cout << "output" << endl; }};int _tmain(int argc, _TCHAR* argv[]){ Point tt; tt.init(); Point::output(); getchar(); return 0;}
上面代码编译后运行结果如下:
// ConsoleApplication6.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include <iostream>#include <string>using namespace std;class Point{public: Point(); static string namee; void init(); static void output(); //类的静态方法};Point::Point(){}string Point::namee = "xxyy"; //静态变量初始化void Point::init(){ cout << "init" << endl;}void Point::output(){ cout << "output" << endl;}int _tmain(int argc, _TCHAR* argv[]){ Point tt; tt.init(); Point::output(); cout << Point::namee << endl; getchar(); return 0;}
上面脚本编译后运行结果如下:
FR:徐海涛(hunk Xu)
阅读全文
0 0
- 静态(C#)
- C#:静态与非静态
- C++: 静态调用
- C++_静态成员
- c 静态库
- C中的静态变量
- 安装C静态库
- C中的静态库
- C#:静态构造函数
- c静态函数
- C++_静态成员
- C/C++静态变量
- C语言静态函数
- [C++] 静态变量基本知识
- C 静态变量
- C语言静态函数
- C++_静态成员
- 静态查找_Search.c
- MSF学习笔记(10)
- 数据结构中代码相关
- VR 技术与新伦理问题
- tomcat 报错
- php怎么杀死后台进程
- c++ 静态
- Tensorflow常用基本概念与函数(二)
- Retrofit2.0通俗易懂的学习姿势,Retrofit2.0 + OkHttp3 + Gson + RxJava
- POJ-2240 Arbitrage
- SQL更新多行数据为不同的值如何实现?
- hello world
- ORACLE 查看RMAN的备份信息总结
- 解决Installation failed with message INSTALL_FAILED_NO_MATCHING_ABIS
- Golang json解析