Click here to Skip to main content
15,914,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVC7 deployment files? Pin
Jason Henderson13-Feb-03 11:15
Jason Henderson13-Feb-03 11:15 
AnswerRe: VC7 deployment files? Pin
Joaquín M López Muñoz13-Feb-03 11:30
Joaquín M López Muñoz13-Feb-03 11:30 
GeneralRe: VC7 deployment files? Pin
Jason Henderson13-Feb-03 17:08
Jason Henderson13-Feb-03 17:08 
GeneralHelp saving large formatted text to database Pin
ElizabethC13-Feb-03 11:09
ElizabethC13-Feb-03 11:09 
GeneralRe: Help saving large formatted text to database Pin
David Salter13-Feb-03 11:54
David Salter13-Feb-03 11:54 
GeneralRe: Help saving large formatted text to database Pin
Anonymous13-Feb-03 12:21
Anonymous13-Feb-03 12:21 
GeneralHELP! C++ Assignement Operator Problem Pin
Anton A. Loukine13-Feb-03 11:05
Anton A. Loukine13-Feb-03 11:05 
GeneralRe: HELP! C++ Assignement Operator Problem Pin
Joaquín M López Muñoz13-Feb-03 11:22
Joaquín M López Muñoz13-Feb-03 11:22 
Hi Anton,
Your class lacks a suitable copy constructor. The problem lies here:
m3 = m1 * m2;
The expression m1 * m2 invokes matrix::operator *, which correctly builds the resulting matrix and returns it. But what m3 is being assigned is not that matrix, but a copy of it. As you haven't provided a copy constructor, the compiler uses the default one, which simply copies the object memberwise: so, the copied result member m really points to the same memory block as the matrix calculated in matrix::operator *; by the time matrix::operator = enters into play, the internally calculated matrix has been destroyed, and the copied result points to non-valid memory.
More generally, when any function returns an object of whatever type, what the caller of the function gets is not the internal object, but rather a copy of it. The copy constructor is always implicitly called.
The morale is: copy constructors and assignment operators come in pairs, you cannot write one without writing the other. Keep this in mind and you'll save yourself a lot of trouble.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralRe: HELP! C++ Assignement Operator Problem Pin
Anton A. Loukine13-Feb-03 11:33
Anton A. Loukine13-Feb-03 11:33 
GeneralRe: HELP! C++ Assignement Operator Problem Pin
Roger Allen13-Feb-03 22:50
Roger Allen13-Feb-03 22:50 
GeneralRe: HELP! C++ Assignement Operator Problem Pin
João Paulo Figueira13-Feb-03 11:57
professionalJoão Paulo Figueira13-Feb-03 11:57 
GeneralHelp!!..with List container Pin
Sal R.13-Feb-03 10:55
Sal R.13-Feb-03 10:55 
GeneralRe: Help!!..with List container Pin
Christian Graus13-Feb-03 11:15
protectorChristian Graus13-Feb-03 11:15 
GeneralRunning a program at startup ! Pin
Hadi Rezaee13-Feb-03 10:06
Hadi Rezaee13-Feb-03 10:06 
GeneralRe: Running a program at startup ! Pin
Navin13-Feb-03 10:27
Navin13-Feb-03 10:27 
GeneralRe: Running a program at startup ! Pin
Hadi Rezaee13-Feb-03 10:34
Hadi Rezaee13-Feb-03 10:34 
GeneralRe: Running a program at startup ! Pin
Scorp1us13-Feb-03 10:27
Scorp1us13-Feb-03 10:27 
GeneralRe: Running a program at startup ! Pin
Hadi Rezaee13-Feb-03 10:35
Hadi Rezaee13-Feb-03 10:35 
GeneralRe: Running a program at startup ! Pin
Anonymous13-Feb-03 16:55
Anonymous13-Feb-03 16:55 
GeneralRe: Running a program at startup ! Pin
Hadi Rezaee13-Feb-03 19:52
Hadi Rezaee13-Feb-03 19:52 
GeneralRe: Running a program at startup ! Pin
palbano13-Feb-03 10:44
palbano13-Feb-03 10:44 
GeneralRe: Running a program at startup ! Pin
Christian Graus13-Feb-03 10:54
protectorChristian Graus13-Feb-03 10:54 
GeneralRe: Running a program at startup ! Pin
Hadi Rezaee13-Feb-03 11:04
Hadi Rezaee13-Feb-03 11:04 
QuestionCan CBitmapButton load bitmap from disk ? Pin
akulkarni13-Feb-03 8:58
akulkarni13-Feb-03 8:58 
GeneralCD burning. Pin
Tili13-Feb-03 8:09
Tili13-Feb-03 8:09 

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.