#include "stdafx.h"
#include<iostream>
#include <string>
using namespace std;
class Point
{
public:
Point(): m_x(0),m_y(0) //無參的建構函式
}
Point(double x, double y) //兩個引數的建構函式
m_x = x;
m_y = y;
Point(const Point& srcPoint) //複製建構函式
m_x = srcPoint.m_x;
m_y = srcPoint.m_y;
void setPoint(int x, int y)
void dispay()
cout<<"X = "<<m_x<<" "<<"Y = "<<m_y<<endl;
private:
double m_x;
double m_y;
};
void main()
Point p1; // 無參的建構函式
Point p2(1, 2); //兩個引數的建構函式
Point p3 = p2; // 複製建構函式
p3.setPoint(3, 4);
p3.dispay();
#include "stdafx.h"
#include<iostream>
#include <string>
using namespace std;
class Point
{
public:
Point(): m_x(0),m_y(0) //無參的建構函式
{
}
Point(double x, double y) //兩個引數的建構函式
{
m_x = x;
m_y = y;
}
Point(const Point& srcPoint) //複製建構函式
{
m_x = srcPoint.m_x;
m_y = srcPoint.m_y;
}
void setPoint(int x, int y)
{
m_x = x;
m_y = y;
}
void dispay()
{
cout<<"X = "<<m_x<<" "<<"Y = "<<m_y<<endl;
}
private:
double m_x;
double m_y;
};
void main()
{
Point p1; // 無參的建構函式
Point p2(1, 2); //兩個引數的建構函式
Point p3 = p2; // 複製建構函式
p3.setPoint(3, 4);
p3.dispay();
}