error LNK2019

So, I did some searching on my own, and found this little post:
http://www.cplusplus.com/forum/windows/3158/

But, I am at a lost to how this solves my problem....
Which is that i get the LNK2019 error.

Here is my code, I wont place the myStack.cpp file in, i triple checked it over.

mystack.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef H_myStack
#define H_myStack

#include <iostream>
#include <cassert>

using namespace std;

template<class Type>
public class stackType
{
public:
	const stackType<Type>& operator=(const stackType<Type>&);
	//overload the assignment operator = 
	void initalizeStack();
	//Function to intialize the stack to an empty state
	//Postcondtion: stackTop = 0;
	bool isEmptyStack();
	//Function to determine if the stack is empty
	//Postcondition: Returns true when stack is empty
	//				 else, it returns false
	bool isFullStack();
	//Function to determins if the stack is full
	//Postcindition: Returns true if the stack is full
	//				 else, it returns false 
	void destroyStack();
	//Function to remove everything from the stack
	//Postcondition: stackTop = 0;
	void push(const Type& newItem);
	//Function to add an item to the top of the stack
	//Precondition: The stack exists and is not full
	//Post condition: The stack is  changed and newItem is on top
	Type top();
	/*Function to return the top element of the stack
	Precondition: the stack exists and is not empty
	PostCondition: if the stack is empty, the program terminates,
				   else the top item of the stack is returned
    */ 
	void pop();
	/*Function to remove the top item of the stack
	Precondition: the stack exists and is not empty
	Postcondition: the stack is changed, and the top item is removed
	*/
	stackType(int stackSize = 100);
	/*constructor
	creates an array of the size stackSize to hold
	the stacks items. The default is 100.
	Postcondition: The variable list contains the base address of the array
				  stackTop = 0; and maxStackSize = stackSize;
	*/
	stackType(const stackType<Type>& otherStack);
	/*copy constructor*/ 
	~stackType();
	/*destructor
	removes all the items from the stack
	postcondition: the array (list) holding the stack's items is deleted
	*/
private:
	int maxStackSize;//variable to store the maximum stack size
	int stackTop;	 //variable to point to the top of the stack
	Type *list;		 //Pointer to the array that holds the stack items

	void copyStack(const stackType<Type>& otherStack);
	/*Function to make a copy of the other stack
	PostCondition: a copy of otherStack is created and 
				   assigned to this stack*/
};


#endif; 


-------------------------------

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
#include <iostream>
#include "myStack.h"

using namespace std;

int main()
{
	stackType<int> intStack(50);//creates a stack of type int with 50 places
	stackType<int> tempStack;   //creates a temp stack of type int to store intStack elements

	intStack.push(23);
	intStack.push(45);
	intStack.push(38);

	tempStack = intStack;		//copy intStack into tempStack

	cout << "tempStack element: ";

	while (!tempStack.isEmptyStack())
	{
		cout << tempStack.top()<< " ";
		tempStack.pop();
	}
	
	cout << endl;

	cout << "The top element of intStack: " << intStack.top() << endl;
	return 0;
}


And here are my errors

Errors

------ Build started: Project: example 7-1, Configuration: Debug Win32 ------
Compiling...
myStackIMP.cpp
Linking...
main.obj : error LNK2028: unresolved token (0A0002B1) "public: class stackType<int> const & __thiscall stackType<int>::operator=(class stackType<int> const &)" (??4?$stackType@H@@$$FQAEABV0@ABV0@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2028: unresolved token (0A0002B2) "public: bool __thiscall stackType<int>::isEmptyStack(void)" (?isEmptyStack@?$stackType@H@@$$FQAE_NXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2028: unresolved token (0A0002B3) "public: void __thiscall stackType<int>::push(int const &)" (?push@?$stackType@H@@$$FQAEXABH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2028: unresolved token (0A0002B4) "public: int __thiscall stackType<int>::top(void)" (?top@?$stackType@H@@$$FQAEHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2028: unresolved token (0A0002B5) "public: void __thiscall stackType<int>::pop(void)" (?pop@?$stackType@H@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2028: unresolved token (0A0002B6) "public: __thiscall stackType<int>::stackType<int>(int)" (??0?$stackType@H@@$$FQAE@H@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2028: unresolved token (0A0002B7) "public: __thiscall stackType<int>::~stackType<int>(void)" (??1?$stackType@H@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: __thiscall stackType<int>::~stackType<int>(void)" (??1?$stackType@H@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall stackType<int>::pop(void)" (?pop@?$stackType@H@@$$FQAEXXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: int __thiscall stackType<int>::top(void)" (?top@?$stackType@H@@$$FQAEHXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: bool __thiscall stackType<int>::isEmptyStack(void)" (?isEmptyStack@?$stackType@H@@$$FQAE_NXZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: class stackType<int> const & __thiscall stackType<int>::operator=(class stackType<int> const &)" (??4?$stackType@H@@$$FQAEABV0@ABV0@@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: void __thiscall stackType<int>::push(int const &)" (?push@?$stackType@H@@$$FQAEXABH@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
main.obj : error LNK2019: unresolved external symbol "public: __thiscall stackType<int>::stackType<int>(int)" (??0?$stackType@H@@$$FQAE@H@Z) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)
C:\Documents and Settings\William\My Documents\Visual Studio 2008\Projects\example 7-1\Debug\example 7-1.exe : fatal error LNK1120: 14 unresolved externals
Build log was saved at "file://c:\Documents and Settings\William\My Documents\Visual Studio 2008\Projects\example 7-1\example 7-1\Debug\BuildLog.htm"
example 7-1 - 15 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I don't think it is because I did not include a library, and I am using a CLR Empty project. Should I have used just a simple Empty Project?
Cancel that, I found out why.

I am using template classes, because I am declaring the stack as an ADT, so i have to define it in one place, the myStack.h

Sorry for wasting forum space.
You haven't provided the implementation for stackType, only the definition.
Topic archived. No new replies allowed.