Click here to Skip to main content
16,008,490 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Basic operator overloading Pin
Bram van Kampen6-Jul-08 13:11
Bram van Kampen6-Jul-08 13:11 
GeneralRe: Basic operator overloading Pin
bkelly136-Jul-08 16:01
bkelly136-Jul-08 16:01 
GeneralRe: Basic operator overloading Pin
Saurabh.Garg6-Jul-08 17:51
Saurabh.Garg6-Jul-08 17:51 
GeneralRe: Basic operator overloading Pin
Saurabh.Garg6-Jul-08 18:05
Saurabh.Garg6-Jul-08 18:05 
AnswerRe: Basic operator overloading [modified] Pin
Luc Pattyn6-Jul-08 10:03
sitebuilderLuc Pattyn6-Jul-08 10:03 
GeneralRe: Basic operator overloading Pin
Graham Shanks6-Jul-08 10:37
Graham Shanks6-Jul-08 10:37 
GeneralRe: Basic operator overloading Pin
Luc Pattyn6-Jul-08 11:15
sitebuilderLuc Pattyn6-Jul-08 11:15 
AnswerRe: Basic operator overloading Pin
Dan6-Jul-08 12:54
Dan6-Jul-08 12:54 
The code is fine, the compiler will generate operator= and the copy constructor for you, it's simply implicit instead of explicit.
Rhe default implementation is a simple bitwise copy.
The way the compiler generates the copy is sort of like:
ClassA::ClassA( const ClassA &from)
     :member1( from.member1 )
     ,member2( from.member2 )
     ,.... etc
{}

This is perfectly fine for this class since you don't have any pointers to worry about.
The default for operator= is functionally the same as the copy constructor.

So your code for operator+ is correct.
this is copied to result.
result is modified.
this actually remains constant.
So actually to be on the safe side you should do.
......
CC operator+( CC &source ) const;
......
CC CC::operator+( CC &source ) const   
{
     CC result = *this;
     double sum = source.Query_X() + X;
     result.Set_X( sum );
     return result;
}

GeneralRe: Basic operator overloading Pin
bkelly136-Jul-08 16:03
bkelly136-Jul-08 16:03 
QuestionHow to perform structured exception handling in Windows Vista Pin
V K 26-Jul-08 5:09
V K 26-Jul-08 5:09 
AnswerRe: How to perform structured exception handling in Windows Vista Pin
Stephen Hewitt6-Jul-08 15:37
Stephen Hewitt6-Jul-08 15:37 
GeneralRe: How to perform structured exception handling in Windows Vista Pin
V K 26-Jul-08 17:49
V K 26-Jul-08 17:49 
GeneralRe: How to perform structured exception handling in Windows Vista Pin
Saurabh.Garg6-Jul-08 18:08
Saurabh.Garg6-Jul-08 18:08 
GeneralRe: How to perform structured exception handling in Windows Vista Pin
Stephen Hewitt6-Jul-08 18:28
Stephen Hewitt6-Jul-08 18:28 
QuestionReplacement for IsBadReadPtr in Windows Vista Pin
V K 26-Jul-08 4:46
V K 26-Jul-08 4:46 
AnswerRe: Replacement for IsBadReadPtr in Windows Vista Pin
CPallini6-Jul-08 5:02
mveCPallini6-Jul-08 5:02 
GeneralRe: Replacement for IsBadReadPtr in Windows Vista Pin
V K 26-Jul-08 5:10
V K 26-Jul-08 5:10 
GeneralRe: Replacement for IsBadReadPtr in Windows Vista Pin
CPallini6-Jul-08 5:22
mveCPallini6-Jul-08 5:22 
GeneralRe: Replacement for IsBadReadPtr in Windows Vista Pin
Luc Pattyn6-Jul-08 11:35
sitebuilderLuc Pattyn6-Jul-08 11:35 
GeneralRe: Replacement for IsBadReadPtr in Windows Vista Pin
CPallini6-Jul-08 21:14
mveCPallini6-Jul-08 21:14 
AnswerRe: Replacement for IsBadReadPtr in Windows Vista Pin
Bram van Kampen6-Jul-08 13:24
Bram van Kampen6-Jul-08 13:24 
AnswerRe: Replacement for IsBadReadPtr in Windows Vista Pin
Stephen Hewitt6-Jul-08 15:53
Stephen Hewitt6-Jul-08 15:53 
QuestionDomain Controller SID in WMI Pin
Green Fuze6-Jul-08 1:32
Green Fuze6-Jul-08 1:32 
AnswerRe: Domain Controller SID in WMI Pin
Saurabh.Garg6-Jul-08 2:13
Saurabh.Garg6-Jul-08 2:13 
GeneralRe: Domain Controller SID in WMI Pin
Green Fuze6-Jul-08 4:14
Green Fuze6-Jul-08 4:14 

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.