#include <iostream>
#include "OrderedLL.h"
#include <ctime>
usingnamespace std;
int main()
{
ORDEREDLL<int> X;
ORDEREDLL<int> Y;
ORDEREDLL<int> Z;
int a[5] = {5,9,11,7,2};
int b[4]={2,5,11,4};
int t=0;
for (int i=0; i<5; i++)
{
t = a[i];
X.Insert(t);
}
for (int i=0; i<4; i++)
{
t = b[i];
Y.Insert(t);
}
X.display();
Y.display();
UNION(X, Y, Z);
Z.display();
return 0;
}
The Error I'm getting when i try to run it is: CPSC 131 Project 6-2.obj : error LNK2019: unresolved external symbol "void __cdecl UNION(class ORDEREDLL<int>,class ORDEREDLL<int>,class ORDEREDLL<int>)" (?UNION@@YAXV?$ORDEREDLL@H@@00@Z) referenced in function _main
TL;DR oh well
if you take the time to look at this thank you, could be something really simple I'm just not experienced enough to see it.
The linker is telling you it can't find UNION. This is because UNION is implictly declared at line 30 as a simple function, but you declared UNION to be specialized by type T in your header file. The two are not the same.
Line 30 should be:
UNION<int>(X, Y, Z);
You also have some other issues:
.h line 15. list is declared as private. You can't modify it from inside UNION, since UNION is not a member of ORDEREDLL.
.h line 115, line 121: insert is capitialized in ORDEREDLL.
.h line 102: A, B and AvB are passed by value. This means any modifications to them are lost when UNION exists. It's also inefficient. They should be passed bvy reference.
BTW, your title refers to a problem with a friend function, but I don't see the friend keyword anywhere.
I am having similar issues. @Kentol, since you figured it out, do you think you could help me with my post which is about 4 posts below yours? Nobody has responded to it yet, and my program is due tomorrow. Do you happen to go to CSUF and have Ahmadnia as your teacher? hahahah.