Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Showing DLL function name references in Visual Studio Debugger Pin
Alexander M.,28-Mar-05 13:30
Alexander M.,28-Mar-05 13:30 
GeneralRestarting the process Pin
mpapeo28-Mar-05 12:03
mpapeo28-Mar-05 12:03 
GeneralModal Dialog not block user interation to CControlBar within App Pin
Art Poley28-Mar-05 10:37
Art Poley28-Mar-05 10:37 
GeneralRe: Modal Dialog not block user interation to CControlBar within App Pin
FlyingTinman28-Mar-05 12:43
FlyingTinman28-Mar-05 12:43 
GeneralRe: Modal Dialog not block user interation to CControlBar within App Pin
Art Poley29-Mar-05 2:57
Art Poley29-Mar-05 2:57 
GeneralInsert icon in menu Pin
luizferp28-Mar-05 9:47
luizferp28-Mar-05 9:47 
GeneralRe: Insert icon in menu Pin
Alexander M.,28-Mar-05 13:32
Alexander M.,28-Mar-05 13:32 
Generaltemplate questions Pin
act_x28-Mar-05 9:21
act_x28-Mar-05 9:21 
I created a template class like

template <class T><br />
class CProtectedBuffer  <br />
{<br />
public:	<br />
	int DeQueue(T &cElement);<br />
	int Enqueue(const T  &newElem);<br />
	CProtectedBuffer();<br />
	virtual ~CProtectedBuffer();<br />
private :<br />
	void Enter();<br />
	void Leave();<br />
	CRITICAL_SECTION cs ; <br />
	T t[MAX_PBUF_SIZE] ; <br />
	// T bBuffer[MAX_PBUF_SIZE];<br />
	int objCount;<br />
<br />
	int headIndex ;<br />
	int tailIndex;<br />
	int size ; 	<br />
<br />
};

Now I want to reuse this template to store objects of a custom class which is :

<br />
<br />
class RcvBuffer{<br />
<br />
public : <br />
	RcvBuffer():toolName(""),buffer(0),packetSize(0)<br />
		 {<br />
		 }; <br />
		 ~RcvBuffer(){<br />
			 if(buffer){<br />
				 delete buffer ;<br />
				 buffer = 0 ; <br />
			 }<br />
		 };<br />
<br />
		 const RcvBuffer& operator=(const RcvBuffer &rhs)<br />
		 {<br />
			 if(buffer){<br />
				 delete [] buffer ; <br />
				 buffer = 0;<br />
			 }<br />
			 int sz = rhs.GetPacketSize() ; <br />
			 if(sz){<br />
				 toolName = rhs.GetToolName();<br />
				 packetSize = sz ; <br />
				 buffer = new UINT8[sz] ;<br />
				 for(int i=0;i<sz;i++){<br />
					 buffer[i] = rhs.BufferValueAt(i);<br />
				 }<br />
			 }	<br />
			 return (*this); <br />
<br />
		 };<br />
<br />
		 const int GetPacketSize() const <br />
		 {<br />
			 return packetSize ; <br />
		 };<br />
<br />
		 const UINT8 BufferValueAt(const int &index) const <br />
		 {<br />
			 if(index<packetSize ){<br />
				 return buffer[index];<br />
			 }<br />
			 return 0;<br />
		 };<br />
		 const string& GetToolName() const <br />
		 {<br />
			 return toolName;<br />
		 };<br />
<br />
		 int Clear() <br />
		 {<br />
			 if(buffer){<br />
				 delete buffer ;<br />
				 buffer = 0 ; <br />
			 }<br />
			 packetSize = 0; <br />
			 toolName ="";<br />
<br />
		 };<br />
private : <br />
	string toolName ;<br />
	UINT8 *buffer ;<br />
	int packetSize ; <br />
}; 



Here is the part implementation of the template class
template <class T><br />
CProtectedBuffer<T>::CProtectedBuffer():headIndex(0),tailIndex(0),size(0)<br />
{<br />
//	Before using a critical section, some thread of the process must call the InitializeCriticalSection or <br />
//	InitializeCriticalSectionAndSpinCount function to initialize the object. <br />
	::InitializeCriticalSection(&cs);<br />
<br />
<br />
<br />
}<br />
template <class T><br />
CProtectedBuffer<T>::~CProtectedBuffer()<br />
{<br />
..<br />
..<br />
..<br />
}

I am using the code like

CProtectedBuffer<RcvBuffer > bBuff ;
I am getting the following linker errors :
linking...<br />
<small>EepromServer.obj : error LNK2001: unresolved external symbol "public: __thiscall CProtectedBuffer<class RcvBuffer>::CProtectedBuffer<class RcvBuffer>(void)" (??0?$CProtectedBuffer@VRcvBuffer@@@@QAE@XZ)<br />
EepromServer.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CProtectedBuffer<class RcvBuffer>::~CProtectedBuffer<class RcvBuffer>(void)" (??1?$CProtectedBuffer@VRcvBuffer@@@@UAE@XZ)<br />
Debug/EepromServer.exe : fatal error LNK1120: 2 unresolved externals<br />
Error executing link.exe.</small>

If someone can advise
GeneralRe: template questions Pin
Joaquín M López Muñoz28-Mar-05 10:16
Joaquín M López Muñoz28-Mar-05 10:16 
GeneralRe: template questions Pin
act_x28-Mar-05 10:35
act_x28-Mar-05 10:35 
GeneralPlease help me! Pin
dSolariuM28-Mar-05 8:52
dSolariuM28-Mar-05 8:52 
GeneralRe: Please help me! Pin
David Crow28-Mar-05 9:25
David Crow28-Mar-05 9:25 
Questionmemcpy() not working ? Pin
Amarelia28-Mar-05 7:41
Amarelia28-Mar-05 7:41 
AnswerRe: memcpy() not working ? Pin
David Crow28-Mar-05 9:26
David Crow28-Mar-05 9:26 
GeneralRe: memcpy() not working ? Pin
Amarelia28-Mar-05 19:24
Amarelia28-Mar-05 19:24 
GeneralRe: memcpy() not working ? Pin
David Crow29-Mar-05 3:12
David Crow29-Mar-05 3:12 
GeneralProblems with HHOOK variable Pin
r3dqu33n28-Mar-05 7:08
r3dqu33n28-Mar-05 7:08 
GeneralRe: Problems with HHOOK variable Pin
David Crow28-Mar-05 9:35
David Crow28-Mar-05 9:35 
GeneralRe: Problems with HHOOK variable Pin
r3dqu33n28-Mar-05 9:45
r3dqu33n28-Mar-05 9:45 
GeneralRe: Problems with HHOOK variable Pin
David Crow28-Mar-05 9:51
David Crow28-Mar-05 9:51 
GeneralRe: Problems with HHOOK variable Pin
r3dqu33n28-Mar-05 10:03
r3dqu33n28-Mar-05 10:03 
GeneralRe: Problems with HHOOK variable Pin
David Crow28-Mar-05 10:22
David Crow28-Mar-05 10:22 
GeneralBitmap Data Manipulation Pin
LighthouseJ28-Mar-05 7:07
LighthouseJ28-Mar-05 7:07 
GeneralRe: Bitmap Data Manipulation Pin
Chris Losinger28-Mar-05 10:42
professionalChris Losinger28-Mar-05 10:42 
GeneralRe: Bitmap Data Manipulation Pin
LighthouseJ28-Mar-05 12:23
LighthouseJ28-Mar-05 12:23 

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.