64,683
社区成员
发帖
与我相关
我的任务
分享
typedef struct _Point
{
int x,y;
}Point;
class A
{
public:
A();
Point p;
static Point sp;
};
A::A()
{
p.x=0;
p.y=0;
}
Point A::sp=0; // 1
int A::sp.x=0; // 2
int A::sp.y=0; // 3
int main()
{
A a;
return 0;
}
#include "stdafx.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
//c++ 中的结构体其实就是类,只是默认的访问控制属性不同
//结构体默认的是 public
//类默认的是private
typedef struct _Point
{
int x,y;
_Point()
{
x = 0;
y = 0;
}
_Point(int parameterX, int parameterY)
{
x = parameterX;
y = parameterY;
}
}Point;
class A
{
public:
A();
Point p;
static Point sp;
};
A::A()
{
p.x=0;
p.y=0;
}
Point A::sp(0,0);
int _tmain(int argc, _TCHAR* argv[])
{
A a;
cout << a.sp.x << " "<< a.sp.y << endl;
system("pause");
return 0;
}