亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么運行代碼出現這個,如何解決

error LNK2019: 無法解析的外部符號 "public: __thiscall Teacher::Teacher(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,int)" (??0Teacher@@QAE@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@H@Z),該符號在函數 _main 中被引用

1>E:\C++練習\ConsoleApplication1\Debug\demo-2-xigou.exe : fatal error LNK1120: 1 個無法解析的外部命令


正在回答

2 回答

#include "stdafx.h"

#include <iostream>

#include <stdlib.h>

#include "Coordinate.h"

#include "Line.h"

using namespace std;

/********************************************/

/*對象成員

要求:

? ? ?定義兩個類;

坐標類:Coordinate

數據成員:橫坐標m_iX,縱坐標m_iY

成員函數:構造函數,析構函數,數據成員的封裝函數

線段類:Line

數據成員:點A:m_coorA,點B:m_coorB

成員函數:構造函數,析構函數,數據成員封裝函數,信息打印函數

*/

/********************************************/



int main(void)

{

Line *p = new Line(1,2,3,4);

p->printInfo();

delete p;

p = NULL;

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"

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;

}

//Coordinate.h

#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();

private:

int m_iX;

int m_iY;

};

//Coordinate.cpp

#include "stdafx.h"

#include <iostream>

#include <stdlib.h>

#include "Coordinate.h"


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;

}



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

代碼貼一下唄

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

舉報

0/150
提交
取消
C++遠征之封裝篇(上)
  • 參與學習       103391    人
  • 解答問題       732    個

封裝--面向對象的基石,本教程力求幫助小伙伴們即學即會

進入課程

為什么運行代碼出現這個,如何解決

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號