Click here to Skip to main content
15,564,177 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Does anyone know this c plus plus knowledge? Pin
CPallini15-Jan-13 12:30
mveCPallini15-Jan-13 12:30 
GeneralRe: Does anyone know this c plus plus knowledge? Pin
yu-jian16-Jan-13 4:17
yu-jian16-Jan-13 4:17 
GeneralRe: Does anyone know this c plus plus knowledge? Pin
CPallini16-Jan-13 5:04
mveCPallini16-Jan-13 5:04 
GeneralRe: Does anyone know this c plus plus knowledge? Pin
yu-jian16-Jan-13 18:44
yu-jian16-Jan-13 18:44 
GeneralRe: Does anyone know this c plus plus knowledge? Pin
jschell16-Jan-13 10:10
jschell16-Jan-13 10:10 
AnswerRe: Does anyone know this c plus plus knowledge? Pin
JackDingler16-Jan-13 12:19
JackDingler16-Jan-13 12:19 
GeneralRe: Does anyone know this c plus plus knowledge? Pin
yu-jian16-Jan-13 18:50
yu-jian16-Jan-13 18:50 
GeneralRe: Does anyone know this c plus plus knowledge? Pin
JackDingler17-Jan-13 6:15
JackDingler17-Jan-13 6:15 
Yes.

1. The object is created on the stack.
2. The constructor is called.
3. The destructor is called.
4. The object is then forgotten.

The example you provided is a good demo of how you can introduce locking bugs. Because the object goes out of scope right away, it doesn't really do anything useful.

The proper way to do it is:
C++
CTempLock Lock(&(this->m_Lock));


If you do something like this...

C++
void ProcessLock(const CTempLock & TempLock)
{
  // do stuff to TempLock here....
}

ProcessLock(CTempLock(&(this->m_Lock)));


Then the temporary object will exist for the lifetime of the call.
Questiondeque problem. Does this code has any problem? [solved] Pin
yu-jian14-Jan-13 4:47
yu-jian14-Jan-13 4:47 
AnswerRe: deque problem. Does this code has any problem? Pin
CPallini14-Jan-13 7:59
mveCPallini14-Jan-13 7:59 
GeneralRe: deque problem. Does this code has any problem? Pin
yu-jian14-Jan-13 14:50
yu-jian14-Jan-13 14:50 
GeneralRe: deque problem. Does this code has any problem? Pin
yu-jian14-Jan-13 17:02
yu-jian14-Jan-13 17:02 
QuestionCDC Problem with coordinates Pin
Argonia14-Jan-13 2:50
professionalArgonia14-Jan-13 2:50 
AnswerRe: CDC Problem with coordinates Pin
Argonia14-Jan-13 22:39
professionalArgonia14-Jan-13 22:39 
GeneralRe: CDC Problem with coordinates Pin
Vaclav_15-Jan-13 10:53
Vaclav_15-Jan-13 10:53 
GeneralRe: CDC Problem with coordinates Pin
Argonia15-Jan-13 22:23
professionalArgonia15-Jan-13 22:23 
QuestionDhcpRequestParams() Pin
Man in the mirror13-Jan-13 20:46
Man in the mirror13-Jan-13 20:46 
AnswerRe: DhcpRequestParams() Pin
Richard MacCutchan13-Jan-13 23:11
mveRichard MacCutchan13-Jan-13 23:11 
QuestionSOLVED From HANDLE to BITMAPINFO - another basic question for gurus Pin
Vaclav_13-Jan-13 6:30
Vaclav_13-Jan-13 6:30 
AnswerRe: From HANDLE to BITMAPINFO - another basic question for gurus Pin
Richard MacCutchan13-Jan-13 6:44
mveRichard MacCutchan13-Jan-13 6:44 
GeneralRe: From HANDLE to BITMAPINFO - another basic question for gurus Pin
Vaclav_13-Jan-13 7:08
Vaclav_13-Jan-13 7:08 
GeneralRe: From HANDLE to BITMAPINFO - another basic question for gurus Pin
Richard MacCutchan13-Jan-13 7:32
mveRichard MacCutchan13-Jan-13 7:32 
QuestionHow to get detail error info from E_FAIL? Pin
Falconapollo11-Jan-13 22:23
Falconapollo11-Jan-13 22:23 
AnswerRe: How to get detail error info from E_FAIL? Pin
«_Superman_»12-Jan-13 0:43
professional«_Superman_»12-Jan-13 0:43 
GeneralRe: How to get detail error info from E_FAIL? Pin
Falconapollo12-Jan-13 1:00
Falconapollo12-Jan-13 1:00 

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.