Click here to Skip to main content
15,886,873 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Visual Studio 2005 Beta 2 Pin
jp-mocs1-Nov-07 7:20
jp-mocs1-Nov-07 7:20 
GeneralRe: Visual Studio 2005 Beta 2 Pin
Larry Mills Sr1-Nov-07 8:12
Larry Mills Sr1-Nov-07 8:12 
QuestionCreating a email server [modified] Pin
bigdenny20031-Oct-07 12:24
bigdenny20031-Oct-07 12:24 
QuestionUsage of bind() Pin
dellthinker31-Oct-07 10:17
dellthinker31-Oct-07 10:17 
AnswerRe: Usage of bind() Pin
JudyL_MD31-Oct-07 10:28
JudyL_MD31-Oct-07 10:28 
AnswerRe: Usage of bind() Pin
Mark Salsbery31-Oct-07 10:43
Mark Salsbery31-Oct-07 10:43 
GeneralRe: Usage of bind() Pin
JudyL_MD1-Nov-07 2:50
JudyL_MD1-Nov-07 2:50 
QuestionHow to use this template with varying sizes? [modified] Pin
Devinder31-Oct-07 9:44
Devinder31-Oct-07 9:44 
I have added <> to the code. My compare function works. I want to ask how to set up the input parameters for compare functions, so that Compare works on 2 different sizes.
-- modified at 12:32 Thursday 1st November, 2007

The following is small sample of the template code I am using.

template <unsigned char sz> class MyStringBase<br />
{<br />
	protected:<br />
		unsigned char Len;<br />
		char Data[sz];<br />
};<br />
<br />
template <unsigned char sz> class MyString : MyStringBase<sz><br />
{<br />
	public:<br />
		MyString () { Len = 0; Data[Len] = 0}<br />
		MyString (const char* src);<br />
		bool Compare(MyString??? rhs, int len);<br />
};<br />
<br />
template<unsigned char sz> MyString <sz>::MyString (const char* src)<br />
{<br />
   long len = strlen(src);<br />
   Len = (unsigned char)((len > sz)? sz: len);<br />
   strncpy(Data, src, Len);<br />
}<br />
<br />
template<unsigned char sz> bool MyString <sz>::Compare(MyString??? rhs, int len)<br />
{<br />
	if (len<0)<br />
		len = Len;<br />
	return ((Len==rhs.Len) && (Len<=len) && (strncmp(Data,rhs.Data,len)==0));<br />
}


Compare function has MyString??? which I need to get filled in so I can do the following

MyString<40> a("Test String 1");<br />
MyString<80> b("Testing of String 2 is good") ;<br />
<br />
bool same4 = a.Compare(b,4);


Thank you for your response.
AnswerRe: How to use this template with varying sizes? Pin
Stephen Hewitt31-Oct-07 19:45
Stephen Hewitt31-Oct-07 19:45 
AnswerRe: How to use this template with varying sizes? Pin
John R. Shaw31-Oct-07 23:48
John R. Shaw31-Oct-07 23:48 
AnswerRe: How to use this template with varying sizes? Pin
Stephen Hewitt1-Nov-07 17:50
Stephen Hewitt1-Nov-07 17:50 
QuestionOnPrint with MFC Pin
mnnca31-Oct-07 7:08
mnnca31-Oct-07 7:08 
AnswerRe: OnPrint with MFC Pin
Gofur Halmurat31-Oct-07 7:10
Gofur Halmurat31-Oct-07 7:10 
GeneralRe: OnPrint with MFC Pin
mnnca31-Oct-07 7:29
mnnca31-Oct-07 7:29 
QuestionRe: OnPrint with MFC Pin
Mark Salsbery31-Oct-07 7:16
Mark Salsbery31-Oct-07 7:16 
AnswerRe: OnPrint with MFC Pin
mnnca31-Oct-07 7:34
mnnca31-Oct-07 7:34 
GeneralRe: OnPrint with MFC Pin
Mark Salsbery31-Oct-07 8:37
Mark Salsbery31-Oct-07 8:37 
GeneralRe: OnPrint with MFC Pin
mnnca31-Oct-07 11:06
mnnca31-Oct-07 11:06 
GeneralRe: OnPrint with MFC Pin
Mark Salsbery1-Nov-07 5:32
Mark Salsbery1-Nov-07 5:32 
GeneralRe: OnPrint with MFC Pin
mnnca2-Nov-07 10:16
mnnca2-Nov-07 10:16 
GeneralRe: OnPrint with MFC Pin
mnnca7-Nov-07 7:58
mnnca7-Nov-07 7:58 
GeneralRe: OnPrint with MFC Pin
Mark Salsbery7-Nov-07 9:45
Mark Salsbery7-Nov-07 9:45 
GeneralRe: OnPrint with MFC Pin
mnnca7-Nov-07 10:54
mnnca7-Nov-07 10:54 
GeneralRe: OnPrint with MFC Pin
Mark Salsbery7-Nov-07 11:04
Mark Salsbery7-Nov-07 11:04 
GeneralRe: OnPrint with MFC Pin
mnnca7-Nov-07 11:13
mnnca7-Nov-07 11:13 

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.