和视频内容一样 但一直过不了编译,求大神指点1
#include <iostream>
#include <stdlib.h>
using namespace std;
class Coordinate
{
private:
int m_iX;
int m_iY;
public:
Coordinate(int x,int y);
~Coordinate();
void setX(int x);
void setY(int y);
int getX();
int getY();
};
class Line
{
private:
Coordinate m_coorA(int x,int y);
Coordinate m_coorB(int x,int y);
public:
Line(int x1,int y1,int x2,int y2);
~Line();
void setA(int x,int y);
void setB(int x,int y);
void printfInfo();
};
Coordinate::Coordinate(int x,int y)
{
m_iX=x;
m_iY=y;
cout<<"Coordinate "<<m_iX<<" "<<m_iY<<endl;
}
Coordinate::~Coordinate()
{
cout<<"~Coordinate "<<m_iX<<" "<<m_iY<<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;
}
Line::Line(int x1,int y1,int x2,int y2):m_coorA(x1,y1),m_coorB(x2,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::printfInfo()
{
cout<<"("<<m_coorA.getX()<<","<<m_coorA.getY()<<")"<<endl;
cout<<"("<<m_coorB.getX()<<","<<m_coorB.getY()<<")"<<endl;
}
int main()
{
Line *p=new Line(1,2,3,4);
p->printfInfo();
delete p;
p=NULL;
system("pause");
return 0;
}