#ifndef _HEAD_H_
#definde _HEAD_H_
class NameClass{
}; 冒号别忘记
#endif
::域名解析符
返回值类型 类名::方法名{.....}
Point.h
- #ifndef _POINT_H_
- #define _POINT_H_
- class Point{
- public :
- Point();
- ~Point();
- int getX(){return x;};
- int getY(){return y;};
- Point(int , int );
- private:
- void setX(int );
- void setY(int );
- int x;
- int y;
- }; //不能落下分号;
- #endif // _POINT_H_
Point.cpp
- #include"Point.h"
- #include <iostream>
- using namespace std;
- Point::Point(){};
- Point::Point(int x, int y){
- this->x = x;
- this->y= y;
- }
- Point::~Point(){
- cout<<"Point Deconstructor"<<endl;
- }
- void Point::setX(int x){
- this->x = x;
- }
- void Point::setY(int y){
- this->y = y;
- }
转载于:https://blog.51cto.com/vincenttung/1172478