Jul 10, 2013 at 1:47pm UTC
I do not understand why my program won't work because of numerous LNK2028 and LNK2019 errors. I am using Microsoft Visual Studio Express 2012. 3 files make up this program. Any help is greatly appreciated! (I have weird names because I have made many copies....)
Here are my files:
Header take 2.h:
#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:
#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]:
#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;
}
Jul 10, 2013 at 1:50pm UTC
1) Please use code tags to make your code more readable
2) How can we help you if you won't tell us what these errors are?
Jul 10, 2013 at 2:06pm UTC
Here are my 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