Errors with unresolved token and unresolved external signal

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
It looks like that the linker knows nothing about the object file with name heading take 2. So it does not see the definitions of class member functions.

Also take into account that your constructor with two parameters has no sense because these parameters do not change values of data members with the same name. In the constructor you change only the parameters themselves
I changed a lot of the program, and now I am getting the error "no match for 'operator<<' in 'std::cout << m.Heading::displayBoxed()'" [line and "no match for 'operator<<' in 'std::cout << m.Heading::displayOneLine()'"

Do you know why this occurs?

Here are the 3 files now:

Heading.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#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 _company);
	void setReport(string _report);
	void displayBoxed(string company, string report);
	void displayOneLine(string company, string report);
};


headinggg.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
36
37
38
39
#include "Heading.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 _company)
{
	if (mcompany == " ")
        mcompany == "ABC Industries";
	else company == _company;
}
//Heading::setReport
void Heading::setReport(string _report)
{
	if (mreport == " ")
        mreport == "Report";
	else report == _report;
}
//Heading::displayBoxed
void Heading::displayBoxed(string company, string report)
{
	cout << company << endl;
	cout << report << endl;
}
//Heading::displayOneLine
void Heading::displayOneLine(string company, string report)
{
	cout << company << report << endl;
}


main.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
36
37
38
39
40
41
42
#include <iostream>
using namespace std;

#include "Heading.h"

//Function prototype:
void displayHeading(Heading);

int main()
{
	string mcompany;
	string mreport;

	cout << "Please enter the company name: ";
	getline(cin, mcompany);

	cout << "Please enter the report name: ";
	getline(cin, mcompany);

	Heading hdg(mcompany, mreport);

	displayHeading(hdg);

	return 0;
}

void displayHeading(Heading m)
{
    string mcompany, mreport;

    cout << "Please enter the company name: ";
	getline(cin, mcompany);

	cout << "Please enter the report name: ";
	getline(cin, mcompany);


	m.setCompany(mcompany);
	m.setReport(mreport);
	cout << m.displayBoxed(mcompany, mreport);
	cout << m.displayOneLine(mcompany, mreport);
}


Topic archived. No new replies allowed.