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

error LNK2019: 无法解析的外部符号

error LNK2019: 无法解析的外部符号

C++
等候稻香 2015-09-16 18:17:27
#include "stdafx.h"#include <iostream>#include <stdlib.h>#include "Coordinate.h"using namespace std;/*****************************************//*对象数组*要求:*     定义Coordinate类*     数据成员分别是m_iX,m_iY;*     分别通过栈和堆实例化长度为3的对象数组*     给数组中元素赋值*     遍历两个数组******************************************/int main(void){ Coordinate coor[3]; coor[0].m_iX = 3; coor[0].m_iY = 5; for (int i = 0; i < 3;i++) { cout <<"coor_X="<<coor[i].m_iX << endl; cout<<"coor_Y="<< coor[i].m_iY << endl; } Coordinate *p = new Coordinate[3]; p->m_iX = 7; p[0].m_iY = 9; p++;//p+=1;p=p+1; p->m_iX = 11; p[0].m_iY = 13; p[1].m_iX=15; p++; p->m_iY = 17; for (int j = 0; j < 3;j++) { cout <<"p_X="<< p->m_iX << endl; cout <<"p_Y="<<p->m_iY << endl; p--; } p++; delete[]p; system("pause");    return 0;}//代码:Line.h#include <iostream>#include <stdlib.h>#include "Coordinate.h"using namespace std;class Line{public: Line(int x1,int y1,int x2,int y2); ~Line(); void setA(int x,int y); void setB(int x,int y); void printInfo();private:Coordinate m_coorA;Coordinate m_coorB;};//Line.cpp#include <iostream>#include <stdlib.h>#include "Coordinate.h"#include "Line.h"using namespace std;Line::Line(int x1,int y1,int x2,int y2):m_cooA(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_coorB.setY(y);}void Line::setB(int x, int y){ m_coorA.setX(x); m_coorB.setY(y);}void Line::printInfo(){ cout <<"("<<m_coorA.getX()<<","<<m_coorA.getY()<<")"<< endl; cout <<"("<<m_coorB.getX()<<","<<m_coorB.getY()<<")"<< endl;}#include <iostream>#include <stdlib.h>using namespace std;class Coordinate{public: Coordinate(); ~Coordinate(); void setX(int x); int getX(); void setY(int y); int getY();public: int m_iX; int m_iY;};#include "stdafx.h"#include <iostream>#include <stdlib.h>#include "Coordinate.h"using namespace std;Coordinate::Coordinate(){ 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;}
查看完整描述

1 回答

?
onemoo

TA贡献883条经验 获得超454个赞

发帖时最好将代码格式化一下, 你这样把缩进都丢了,看着太乱...

查看完整回答
反对 回复 2015-09-16
  • 1 回答
  • 0 关注
  • 1387 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信