首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

Code:BLocks报告no matching function for call to `CPoint:CPoint()'|解决办法

2012-06-14 
Code:BLocks报告no matching function for call to `CPoint::CPoint()|#ifndef CPOINT_H_INCLUDED#define

Code:BLocks报告no matching function for call to `CPoint::CPoint()'|
#ifndef CPOINT_H_INCLUDED
#define CPOINT_H_INCLUDED
class CPoint
{
private:
int x, y;
static int nCount; // nCount用于保存点的个数
public:
CPoint(int px, int py);
CPoint(CPoint&);
~CPoint();
int GetX()const;
int GetY()const;
void SetX(int);
void SetY(int);
void ShowPoint()const;
};
#endif // CPOINT_H_INCLUDED

#include<iostream>
#include "CPoint.h"
using namespace std;
int CPoint::nCount = 0;
CPoint::CPoint(int px, int py)
{
  x = px;
  y = py;
  nCount++;
}
CPoint::CPoint(CPoint& p):x(p.x),y(p.y)
{
  nCount++;
}
CPoint::~CPoint()
{
  nCount --;
}
int CPoint::GetX()const
{
  return x;
}
int CPoint::GetY()const
{
  return y;
}
void CPoint::SetX(int a)
{
  x = a;
}
void CPoint::SetY(int b)
{
  y = b;
}
void CPoint::ShowPoint()const
{
  cout << "The point is (" << GetX() << ","
  << GetY() << ")" << endl;
}

#include<iostream>
#include "CPoint.h"
using namespace std;
int CPoint::nCount = 0;
CPoint::CPoint(int px, int py)
{
  x = px;
  y = py;
  nCount++;
}
CPoint::CPoint(CPoint& p):x(p.x),y(p.y)
{
  nCount++;
}
CPoint::~CPoint()
{
  nCount --;
}
int CPoint::GetX()const
{
  return x;
}
int CPoint::GetY()const
{
  return y;
}
void CPoint::SetX(int a)
{
  x = a;
}
void CPoint::SetY(int b)
{
  y = b;
}
void CPoint::ShowPoint()const
{
  cout << "The point is (" << GetX() << ","
  << GetY() << ")" << endl;
}


#include"CPoint.h"
#include"CLine.h"

#include<iostream>
#include<math.h>
using namespace std;
CLine::CLine()
{
}
CLine::CLine(int x1,int y1,int x2,int y2)
{
  pt1.SetX(x1);
  pt1.SetY(y1);
  pt2.SetX(x2);
  pt2.SetY(y2);
}
CLine::CLine(CPoint p1,CPoint p2):pt1(p1),pt2(p2)
{
}
double CLine::Distance()
{
  double dis = sqrt(pow((pt1.GetX()-pt2.GetX()),2) +
  pow((pt1.GetY()-pt2.GetY()),2));
  return dis;
}
void CLine::ShowLine()const
{
  cout << "The line is (" << pt1.GetX()
  <<"," << pt1.GetY() << ") to ("
  << pt1.GetX() <<"," << pt1.GetY()
  << ")";
}

编译器报错:
求大侠帮忙看看那里错了

[解决办法]
這么多重复代码!!

热点排行