Click here to Skip to main content
15,909,324 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPostThreadMessages lost in DLL Pin
PaulCammy3-Aug-07 5:54
PaulCammy3-Aug-07 5:54 
AnswerRe: PostThreadMessages lost in DLL Pin
Mark Salsbery3-Aug-07 6:07
Mark Salsbery3-Aug-07 6:07 
QuestionRe: PostThreadMessages lost in DLL Pin
PaulCammy4-Aug-07 1:52
PaulCammy4-Aug-07 1:52 
AnswerRe: PostThreadMessages lost in DLL Pin
Mark Salsbery4-Aug-07 6:42
Mark Salsbery4-Aug-07 6:42 
GeneralRe: PostThreadMessages lost in DLL Pin
PaulCammy5-Aug-07 22:23
PaulCammy5-Aug-07 22:23 
GeneralRe: PostThreadMessages lost in DLL Pin
Blake Miller6-Aug-07 5:06
Blake Miller6-Aug-07 5:06 
GeneralRe: PostThreadMessages lost in DLL Pin
Mark Salsbery6-Aug-07 5:06
Mark Salsbery6-Aug-07 5:06 
Questiondifferentiating between literal strings and char pointers [modified] Pin
dburns3-Aug-07 4:48
dburns3-Aug-07 4:48 
Hi,

Suppose I have a method foo that takes a const char* param. I have a case where I can be more efficient if the caller passes in a "quoted literal string" vs the contents of some arbitrary buffer (because I don't have to copy the string data in the first case).

((UPDATE: To be clear, the class with method foo needs to store the supplied string away for later access, internally. For a literal string, it's safe to store the pointer only. For a non-literal, it's necessary to copy the data in case the original caller's buffer goes away or is modified before the class instance goes away.))

Pretty sure the answer is "you can't", but I thought I'd check if anyone can think of a way to overload the method foo such that one version is invoked for

char buff[100];<br />
...<br />
const char* p_buff = buff;<br />
myclass.foo(p_buff)


and the second version is invoked for

myclass.foo("literal string")

?

I can't change the name of foo or have the caller specify explicitly which one they want. This sample is just an illustration.

Thanks!
DB




-- modified at 12:11 Friday 3rd August, 2007
AnswerRe: differentiating between literal strings and char pointers Pin
CPallini3-Aug-07 4:59
mveCPallini3-Aug-07 4:59 
GeneralRe: differentiating between literal strings and char pointers Pin
dburns3-Aug-07 5:03
dburns3-Aug-07 5:03 
GeneralRe: differentiating between literal strings and char pointers Pin
CPallini3-Aug-07 5:07
mveCPallini3-Aug-07 5:07 
GeneralRe: differentiating between literal strings and char pointers Pin
dburns3-Aug-07 5:13
dburns3-Aug-07 5:13 
GeneralRe: differentiating between literal strings and char pointers Pin
CPallini3-Aug-07 5:19
mveCPallini3-Aug-07 5:19 
GeneralRe: differentiating between literal strings and char pointers Pin
dburns3-Aug-07 5:48
dburns3-Aug-07 5:48 
GeneralRe: differentiating between literal strings and char pointers Pin
David Crow3-Aug-07 6:11
David Crow3-Aug-07 6:11 
GeneralRe: differentiating between literal strings and char pointers Pin
dburns3-Aug-07 6:22
dburns3-Aug-07 6:22 
GeneralRe: differentiating between literal strings and char pointers Pin
led mike3-Aug-07 7:16
led mike3-Aug-07 7:16 
GeneralRe: differentiating between literal strings and char pointers Pin
David Crow3-Aug-07 7:18
David Crow3-Aug-07 7:18 
GeneralRe: differentiating between literal strings and char pointers Pin
led mike3-Aug-07 7:15
led mike3-Aug-07 7:15 
QuestionRe: differentiating between literal strings and char pointers Pin
David Crow3-Aug-07 5:10
David Crow3-Aug-07 5:10 
AnswerRe: differentiating between literal strings and char pointers Pin
dburns3-Aug-07 5:43
dburns3-Aug-07 5:43 
AnswerRe: differentiating between literal strings and char pointers Pin
cp98763-Aug-07 18:30
cp98763-Aug-07 18:30 
GeneralRe: differentiating between literal strings and char pointers Pin
dburns4-Aug-07 4:05
dburns4-Aug-07 4:05 
Questionproblem with radio button and UpdateData Pin
m.dietz3-Aug-07 4:13
m.dietz3-Aug-07 4:13 
AnswerRe: problem with radio button and UpdateData Pin
led mike3-Aug-07 4:52
led mike3-Aug-07 4:52 

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.