為什么老提示錯誤?
#include<iostream>
#include"Line.h"
using namespace std;
Line::Line(int x1,int y1,int x2,int y2)
{
cout<<"Line()"<<endl;
}
Line::~Line()
{
cout<<"~Line()"<<endl;
}
void Line::setA(int x,int y)
{
//m_coorA.setX(x);
//m_coorA.setY(y);
}
void Line::setB(int x,int y)
{
m_coorB.setX(x);
m_coorB.setY(y);
}
void Line::printInfo()
{
cout<<"printInfo()"<<endl;
cout<<"("<<m_coorA.getX()<<","<<m_coorA.getY()<<")"<<endl;
cout<<"("<<m_coorB.getX()<<","<<m_coorB.getY()<<")"<<endl;
}
void Line::printInfo() const
{
cout<<"printInfo() const"<<endl;
cout<<"("<<m_coorA.getX()<<","<<m_coorA.getY()<<")"<<endl;
cout<<"("<<m_coorB.getX()<<","<<m_coorB.getY()<<")"<<endl;
}
error C2512: “Coordinate”: 沒有合適的默認(rèn)構(gòu)造函數(shù)可用
2015-12-06
你的坐標(biāo)類都沒有定義,也就找不到Coordinate對象也就是找不到構(gòu)造函數(shù)實例化Coordinate。 ??m_coorA.getX()這個m_coorA是一個對象成員
2015-10-21
你是不是在調(diào)用的時候調(diào)用的是Coordinate這個類的默認(rèn)構(gòu)造函數(shù)?而在Coordinate這類中你把默認(rèn)構(gòu)造函數(shù)給覆蓋了?