Click here to Skip to main content
15,914,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Communication between processes Pin
W00dSt0ck20-Sep-04 4:41
W00dSt0ck20-Sep-04 4:41 
GeneralRe: Communication between processes Pin
Blake Miller20-Sep-04 5:01
Blake Miller20-Sep-04 5:01 
GeneralRe: Communication between processes Pin
0v3rloader20-Sep-04 6:48
0v3rloader20-Sep-04 6:48 
GeneralRe: Communication between processes Pin
Blake Miller20-Sep-04 7:16
Blake Miller20-Sep-04 7:16 
GeneralApplication Wizards for embedded Visual C++ 4 Pin
Jim Crafton20-Sep-04 3:15
Jim Crafton20-Sep-04 3:15 
GeneralRe: Application Wizards for embedded Visual C++ 4 Pin
Jim Crafton20-Sep-04 3:39
Jim Crafton20-Sep-04 3:39 
GeneralCapture screen with DirectX8 Pin
Dani7720-Sep-04 2:59
Dani7720-Sep-04 2:59 
GeneralTemplate Linker Errors... Pin
Milby00720-Sep-04 2:44
Milby00720-Sep-04 2:44 
hi!

i've written a little template class test app & am having real problems trying to build it. it all compiles fine but i get LNK2019 errors for every method of the template class used in 'main'. i've copied the code & build output below, & would really appreciate ANY help you can give. thanks!!
// test.h

#ifndef _TEST_H_
#define _TEST_H_

template <class type> class Test
{
public:
	
	void SetMember(type Val);
	type GetMember();
	
	Test<type>& Copy();
	
private:
	
	type m_Member;
	
};

#endif // _TEST_H_

i've gotta feeling that i've implemented the class methods incorrectly, but really can't see how!?
// test.cpp

#include "test.h"

template <class type>
void Test<type>::SetMember(type Val)
{
	this->m_Member = Val;
}

template <class type>
type Test<type>::GetMember()
{
	return this->m_Member;
}

template <class type>
Test<type>& Test<type>::Copy()
{
	return *this;
}

// main.cpp

#include <iostream>
#include "test.h"

using namespace std;

int main()
{
	Test<int> tst;
	
	cout << "TEMPLATE TEST PROGRAM..." << endl << endl;
	
	tst.SetMember(68);
	
	cout << "TEST CLASS RETURNS\t" << tst.GetMember() << endl;
	
	Test<int> tst2 = tst.Copy();
	
	cout << "TEST CLASS 2 RETURNS\t" << tst2.GetMember() << endl;
	
	cout << "Press any key to end..." << endl;
	
	cin.get();
}

the above code produces the following errors on build...
------ Build started: Project: template_test, Configuration: Debug Win32 ------

Compiling...
test.cpp
Linking...

main.obj : error LNK2019: unresolved external symbol "public: class Test<int> & __thiscall Test<int>::Copy(void)" (?Copy@?$Test@H@@QAEAAV1@XZ) referenced in function _main

main.obj : error LNK2019: unresolved external symbol "public: int __thiscall Test<int>::GetMember(void)" (?GetMember@?$Test@H@@QAEHXZ) referenced in function _main

main.obj : error LNK2019: unresolved external symbol "public: void __thiscall Test<int>::SetMember(int)" (?SetMember@?$Test@H@@QAEXH@Z) referenced in function _main

Debug/template_test.exe : fatal error LNK1120: 3 unresolved externals

template_test - 4 error(s), 0 warning(s)


---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped

GeneralRe: Template Linker Errors... Pin
Arsalan Malik20-Sep-04 2:49
Arsalan Malik20-Sep-04 2:49 
GeneralRe: Template Linker Errors... Pin
Milby00720-Sep-04 4:47
Milby00720-Sep-04 4:47 
GeneralRe: Template Linker Errors... Pin
Bob Stanneveld20-Sep-04 6:27
Bob Stanneveld20-Sep-04 6:27 
GeneralVirtual Keyboard Pin
racing5720-Sep-04 2:35
racing5720-Sep-04 2:35 
GeneralRe: Virtual Keyboard Pin
Blake Miller20-Sep-04 5:04
Blake Miller20-Sep-04 5:04 
GeneralRe: Virtual Keyboard Pin
racing5720-Sep-04 5:11
racing5720-Sep-04 5:11 
GeneralRe: Virtual Keyboard Pin
cwetze0115-Dec-04 15:55
cwetze0115-Dec-04 15:55 
GeneralEdit Box from funtion Pin
W00dSt0ck20-Sep-04 2:14
W00dSt0ck20-Sep-04 2:14 
GeneralRe: Edit Box from funtion Pin
Alpha Siera20-Sep-04 3:00
Alpha Siera20-Sep-04 3:00 
GeneralRe: Edit Box from funtion Pin
W00dSt0ck20-Sep-04 3:18
W00dSt0ck20-Sep-04 3:18 
GeneralRe: Edit Box from funtion Pin
Alpha Siera20-Sep-04 3:31
Alpha Siera20-Sep-04 3:31 
GeneralRe: Edit Box from funtion Pin
Arsalan Malik20-Sep-04 3:08
Arsalan Malik20-Sep-04 3:08 
GeneralRe: Edit Box from funtion Pin
W00dSt0ck20-Sep-04 4:10
W00dSt0ck20-Sep-04 4:10 
GeneralRe: Edit Box from funtion Pin
David Crow20-Sep-04 5:36
David Crow20-Sep-04 5:36 
Generalglobal hotkey: i dont get the WM_HOTKEY message Pin
Member 134487420-Sep-04 2:00
Member 134487420-Sep-04 2:00 
GeneralInternetGetConnectedState and LAN Pin
WernerP20-Sep-04 1:05
WernerP20-Sep-04 1:05 
QuestionHow to lock a CFile in VC++ 6.0? Pin
Neeranjan19-Sep-04 22:26
Neeranjan19-Sep-04 22:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.