为了账号安全,请及时绑定邮箱和手机立即绑定

5 1 F:\C++练习\LineAndCoordinate\coordinate.cpp [Error] prototype for 'Coordinate::Coordinate(int, int)' does not match any in class 'Coordinate'

#include"coordinate.h"

#include<iostream>

using namespace std;


Coordinate::Coordinate(int x,int y)

{

m_iX=x;m_iY=y;

cout<<"Coordinate()"<<endl;

}


Coordinate::~Coordinate(){

cout<<"~Coordinate()"<<endl;

}

void Coordinate::setX(int x){

m_iX=x;

}

int Coordinate::getX(){

return m_iX;

}

void Coordinate::setY(int y){

m_iY=y;

}

int Coordinate::getY(){

return m_iY;

}

class Coordinate

{

public:

  Coordinate(int x,int y);

~Coordinate();

void setX(int x);

int getX();

void setY(int y);

int getY();

private:

int m_iX;

int m_iY;

};


正在回答

2 回答

Coordinate没有默认构造函数 ,Line要使用初始化列表

Line::Line(int x1,int y1,int x2,int y2):m_coorA(x1,y1),m_coorB(x2,y2){}

仔细听老师最后说的!!!

0 回复 有任何疑惑可以回复我~

5 1 F:\C++练习\LineAndCoordinate\coordinate.cpp [Error] prototype for 'Coordinate::Coordinate(int, int)' does not match any in class 'Coordinate'

3 7 F:\C++练习\LineAndCoordinate\coordinate.h [Error] candidates are: Coordinate::Coordinate(const Coordinate&)

6 2 F:\C++练习\LineAndCoordinate\coordinate.h [Error] Coordinate::Coordinate()

28 F:\C++练习\LineAndCoordinate\Makefile.win recipe for target 'coordinate.o' failed


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
C++远征之封装篇(下)
  • 参与学习       70919    人
  • 解答问题       514    个

封装--面向对象三大特征之一,通过案例让C++所学知识融会贯通

进入课程

5 1 F:\C++练习\LineAndCoordinate\coordinate.cpp [Error] prototype for 'Coordinate::Coordinate(int, int)' does not match any in class 'Coordinate'

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信