이것은 대학을위한 C + 숙제를위한 것이므로 아직 초보자이지만이 오류를 본 적이 한번도 없습니다. 이 프로그램은 단순한 클래스를 만들고 두 개의 클래스 객체를 만들고 클래스의 속성을 사용자에게 보내어 모든 속성을 Set Get 함수로 검사해야합니다. 누군가가이 오류를 설명하고 그것을 예방/수정하는 방법을 가르쳐 주면 감사하겠습니다. 감사합니다!C++ 오류 오류 LNK2019 : 해결되지 않은 외부 기호, 구문 오류?
이 전체 오류입니다 : 오류 1 오류 LNK2019 : 확인되지 않은 외부 기호 "공공 : __thiscall 송장 : 송장 (클래스 표준 : : basic_string, 클래스 표준 : : 할당>, 클래스 표준 : : basic_string, 클래스 표준 : : 할당 자>, int, int) "참조 (QAE @ V? $ basic_string @ DU? char_traits @ D @ std @@ V? $ allocator @ D @ 2 @ std @@ 0HH @ Z) 기능 _main의 C에서 : 1 개 확인되지 않은 외부의 C : \ 사용자 \ PBirkholtz001 바탕 화면 \ 시험 결승 \ \ invoicerExamQuest1 디버그 \ \ 사용자 \ PBirkholtz001 바탕 화면 \ 시험 결승 \ \ invoicerExamQuest1 \ invoicerExamQuest1 Source.obj invoicerExamQuest1
오류 2 오류 LNK1120 \ \ invoicerExamQuest1.exe invoicerExamQuest1
내 헤더 파일은 다음과 같습니다
#ifndef INVOICE_H
#define INVOICE_H
#include <iostream>
#include <string>
using namespace std;
class invoice{
private:
// Variables for the class
string partNum;
string desc;
int quant;
int price;
public:
//constructor
invoice(string partNum = "f000", string desc = "HardWare", int quant = 1, int price = 0);
//////////////////get set functions////////////////////////////////
void setpartnum(string a){
partNum = a;
}
string getpartnum(){
return partNum;
}
//////////////////////////////////////////////////
void setdesc(string b){
desc = b;
}
string getdesc(){
return partNum;
}
/////////////////////////////////////////////////
void setquant(int x){
quant = x;
}
int getquant(){
return quant;
}
////////////////////////////////////////////////
void setprice(int y){
quant = y;
}
int getprice(){
return price;
}
/////////////////Total function//////////////////////////////
int invoiceAmount(){
return quant * price;
}
///////////////////////////////////////////////
};
#endif
이 내 소스 파일입니다
#include <iostream>
#include "Header.h"
using namespace std;
int main(){
invoice invoice1;
invoice1.setpartnum("SD001");
invoice1.setdesc("PNY 100Gb Solid State Drive");
invoice1.setprice(120);
invoice1.setquant(1);
cout << "you have ordered: " << invoice1.getquant() << " " << invoice1.getpartnum() << endl;
cout << " which will cost: $" << invoice1.getprice() << " your total comes to: $" << invoice1.invoiceAmount() << endl;
system("pause");
}
설명 : 당신은 빈 생성자를 만든
당신은이 라인을 변경하여 구현할 수 있을까? 왜 "CPP"파일에 메서드를 만들지 않습니까? 예. 'header.h'와'header.cpp' –