// 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)