My program will not run because of error LNK2028 "unresolved token" and error LNK2019 "unresolved external signal" and I do not know why. My teacher says that I need to make the constructor and display functions display class variables in different formats, but I do not know what to do with that. Here are my 3 files:
Header take 2.h:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
#pragma once
#include <iostream>
#include <string>
using namespace std;
class Heading
{
private:
string company, report;
public:
//Default constructor
Heading(void);
//Constructor
Heading(string company, string report);
//set and display company and report name
void setCompany(string c);
void setReport(string r);
void displayBoxed();
void displayOneLine();
};
|
heading take 2.cpp:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include "header take 2.h"
//Default constructor
Heading::Heading(void)
{
company = report = " ";
}
//Constructor
Heading::Heading(string company, string report)
{
company = "ABC Industries";
report = "Report";
}
//Heading:setCompany
void Heading::setCompany(string c)
{
company = c;
}
//Heading::setReport
void Heading::setReport(string r)
{
report = r;
}
//Heading::displayBoxed
void Heading::displayBoxed()
{
cout << company << endl;
cout << report << endl;
}
//Heading::displayOneLine
void Heading::displayOneLine()
{
cout << company << report << endl;
}
|
Source1. cpp [main]:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
#include <iostream>
using namespace std;
#include "header take 2.h"
int main()
{
string company;
string report;
cout << "Please enter the company name: ";
cin >> company;
cout << "Please enter the report name: ";
cin >> report;
Heading hdg;
hdg.setCompany(company);
hdg.setReport(report);
hdg.displayBoxed();
hdg.displayOneLine();
return 0;
}
|
Here are the errors:
Error 1 error LNK2028: unresolved token (0A0003C9) "public: __thiscall Heading::Heading(void)" (??0Heading@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 2 error LNK2028: unresolved token (0A0003CA) "public: void __thiscall Heading::setCompany(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setCompany@Heading@@$$FQAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 3 error LNK2028: unresolved token (0A0003CB) "public: void __thiscall Heading::setReport(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setReport@Heading@@$$FQAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 4 error LNK2028: unresolved token (0A0003CC) "public: void __thiscall Heading::displayBoxed(void)" (?displayBoxed@Heading@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 5 error LNK2028: unresolved token (0A0003CD) "public: void __thiscall Heading::displayOneLine(void)" (?displayOneLine@Heading@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 6 error LNK2019: unresolved external symbol "public: __thiscall Heading::Heading(void)" (??0Heading@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 7 error LNK2019: unresolved external symbol "public: void __thiscall Heading::setCompany(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setCompany@Heading@@$$FQAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 8 error LNK2019: unresolved external symbol "public: void __thiscall Heading::setReport(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?setReport@Heading@@$$FQAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 9 error LNK2019: unresolved external symbol "public: void __thiscall Heading::displayBoxed(void)" (?displayBoxed@Heading@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 10 error LNK2019: unresolved external symbol "public: void __thiscall Heading::displayOneLine(void)" (?displayOneLine@Heading@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ) c:\Users\Owner\documents\visual studio 2012\Projects\ClassLibrary2\ClassLibrary2\Source1.obj ClassLibrary2
Error 11 error LNK1120: 10 unresolved externals c:\users\owner\documents\visual studio 2012\Projects\ClassLibrary2\Debug\ClassLibrary2.dll ClassLibrary2