Click here to Skip to main content
15,918,041 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generallocale currency Pin
vcseeker15-Apr-03 21:57
vcseeker15-Apr-03 21:57 
GeneralRe: locale currency Pin
David Crow16-Apr-03 2:18
David Crow16-Apr-03 2:18 
GeneralIE toolbar disappearing buttons Pin
xenonii15-Apr-03 20:54
xenonii15-Apr-03 20:54 
GeneralRe: IE toolbar disappearing buttons Pin
xenonii16-Apr-03 2:22
xenonii16-Apr-03 2:22 
GeneralDDI hooking Pin
vikramlinux15-Apr-03 20:21
vikramlinux15-Apr-03 20:21 
GeneralRe: DDI hooking Pin
Dominik Reichl15-Apr-03 23:13
Dominik Reichl15-Apr-03 23:13 
GeneralRe: DDI hooking Pin
vikramlinux15-Apr-03 23:17
vikramlinux15-Apr-03 23:17 
GeneralTwo strange operations with this pointer. Pin
George215-Apr-03 17:18
George215-Apr-03 17:18 
Hi, everyone!

I am reading the source codes of another buddie and
I often see strange operation with "this" pointer.
It really makes puzzled. Here are two cases,

Sample 1:
--------
class A {

public:

memberFunction(const A& a)
{
*this = a;
}

};

int main()
{
A a;
A b;
a.memberFunction(b);
return 1;
}
--------

I think in the first case, the statement "*this = a" calls the
class default assignment operator,

--------
void A::opeartor = (const A&).
--------

Am I correct?

Sample 2:
--------
class A {

public:

void memberFunction(A* a)
{
this = a;
}

};

int main()
{
A a;
A b;
a.memberFunction(&b);
return 1;
}
--------

I think in the latter case, the statement "this = a" is not correct since
the value of this pointer can not be modified. But I am not sure about
it. Am I also correct?


Thanks in advance,
George
GeneralRe: Two strange operations with this pointer. Pin
Michael Dunn15-Apr-03 19:36
sitebuilderMichael Dunn15-Apr-03 19:36 
GeneralRe: Two strange operations with this pointer. Pin
George215-Apr-03 19:55
George215-Apr-03 19:55 
GeneralRe: Two strange operations with this pointer. Pin
Michael Dunn15-Apr-03 20:10
sitebuilderMichael Dunn15-Apr-03 20:10 
GeneralRe: Two strange operations with this pointer. Pin
George215-Apr-03 20:11
George215-Apr-03 20:11 
QuestionWill this case cause memory leak? Pin
George215-Apr-03 16:15
George215-Apr-03 16:15 
AnswerRe: Will this case cause memory leak? Pin
Dave Bryant15-Apr-03 16:40
Dave Bryant15-Apr-03 16:40 
GeneralRe: Will this case cause memory leak? Pin
George215-Apr-03 16:53
George215-Apr-03 16:53 
GeneralLooping in C++ Pin
John DeVito15-Apr-03 15:20
John DeVito15-Apr-03 15:20 
GeneralRe: Looping in C++ Pin
Taka Muraoka15-Apr-03 15:29
Taka Muraoka15-Apr-03 15:29 
GeneralRe: Looping in C++ Pin
John L. DeVito15-Apr-03 16:10
professionalJohn L. DeVito15-Apr-03 16:10 
GeneralRe: Looping in C++ Pin
Taka Muraoka15-Apr-03 16:12
Taka Muraoka15-Apr-03 16:12 
GeneralRe: Looping in C++ Pin
Michael Dunn15-Apr-03 19:39
sitebuilderMichael Dunn15-Apr-03 19:39 
GeneralRe: Looping in C++ Pin
Toni7816-Apr-03 21:45
Toni7816-Apr-03 21:45 
Questiondouble table[][] vs double** table? Pin
Anonymous15-Apr-03 12:46
Anonymous15-Apr-03 12:46 
AnswerRe: double table[][] vs double** table? Pin
Chris Losinger15-Apr-03 13:02
professionalChris Losinger15-Apr-03 13:02 
GeneralRe: double table[][] vs double** table? Pin
Anonymous15-Apr-03 13:16
Anonymous15-Apr-03 13:16 
AnswerRe: double table[][] vs double** table? Pin
Dave Bryant15-Apr-03 13:04
Dave Bryant15-Apr-03 13:04 

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.