Click here to Skip to main content
15,923,376 members
Home / Discussions / C#
   

C#

 
QuestionPassing char array to c++ function Pin
Blubbo7-Sep-06 3:13
Blubbo7-Sep-06 3:13 
QuestionRe: Passing char array to c++ function Pin
Nader Elshehabi7-Sep-06 4:48
Nader Elshehabi7-Sep-06 4:48 
AnswerRe: Passing char array to c++ function Pin
Judah Gabriel Himango7-Sep-06 4:57
sponsorJudah Gabriel Himango7-Sep-06 4:57 
AnswerRe: Passing char array to c++ function Pin
Judah Gabriel Himango7-Sep-06 4:57
sponsorJudah Gabriel Himango7-Sep-06 4:57 
QuestionQuestion about Objects Pin
Chrismaster7-Sep-06 2:08
Chrismaster7-Sep-06 2:08 
AnswerRe: Question about Objects Pin
SeMartens7-Sep-06 2:23
SeMartens7-Sep-06 2:23 
AnswerRe: Question about Objects Pin
Not Active7-Sep-06 2:25
mentorNot Active7-Sep-06 2:25 
AnswerRe: Question about Objects Pin
mikone7-Sep-06 2:26
mikone7-Sep-06 2:26 
lets say it like microsoft would: "this is not a bug, it's a feature!"

you just were introduced to the worl of object oriented programming.
the problem which has occoured is not really a problem.
the object passed to the function will be passed as a reference.
that means you will just permit its address and the function will access
the original object.
As you have just noticed there is no new object.
But stop, there is. You wrote:
<br />
asMySprite = new AdnimatedSprite();<br />

this line means you're allocating some memory on the heap for a new instance of the class animated sprite. the address of the beginning of this memory (i guess in .net its a bit different...) is assigned to the asMySprite variable. In the next line you write:
<br />
asMySprite = asfOrigin;<br />

Now you assign the address of the ORIGINAL object to the variable. this means you "overwrote" the variable and it isn't pointing to the new object anymore.
Thats why this error occurs.

To avoid this situation, you should make yourself familiar with references and "deep copies" of objects.

There is no general solution for your problem since the circumstances are different for each class...

Good luck,
mik
AnswerThanks! Pin
Chrismaster7-Sep-06 2:34
Chrismaster7-Sep-06 2:34 
AnswerRe: Question about Objects Pin
guygo7-Sep-06 2:48
guygo7-Sep-06 2:48 
QuestionLimiting ListObjects in Excel from growing row-wise Pin
esskay19797-Sep-06 1:51
esskay19797-Sep-06 1:51 
QuestionAvoiding 2 same processes Pin
stancrm7-Sep-06 1:48
stancrm7-Sep-06 1:48 
AnswerRe: Avoiding 2 same processes Pin
User 66587-Sep-06 2:00
User 66587-Sep-06 2:00 
Questionframework including Pin
erfi7-Sep-06 1:17
erfi7-Sep-06 1:17 
AnswerRe: framework including Pin
Utkarshraj Atmaram7-Sep-06 1:55
Utkarshraj Atmaram7-Sep-06 1:55 
Questionhow to call a method from another thread? Pin
michal.kreslik7-Sep-06 0:44
michal.kreslik7-Sep-06 0:44 
AnswerRe: how to call a method from another thread? Pin
Bijesh7-Sep-06 0:53
Bijesh7-Sep-06 0:53 
GeneralRe: how to call a method from another thread? Pin
michal.kreslik7-Sep-06 1:57
michal.kreslik7-Sep-06 1:57 
QuestionWindows API overriding in C# Pin
hoangvantien7-Sep-06 0:39
hoangvantien7-Sep-06 0:39 
AnswerRe: Windows API overriding in C# Pin
Judah Gabriel Himango7-Sep-06 4:55
sponsorJudah Gabriel Himango7-Sep-06 4:55 
AnswerRe: Windows API overriding in C# Pin
Jun Du7-Sep-06 5:04
Jun Du7-Sep-06 5:04 
QuestionTreeView Control in WinForms Pin
aka21097-Sep-06 0:26
aka21097-Sep-06 0:26 
AnswerRe: TreeView Control in WinForms Pin
Ed.Poore7-Sep-06 0:57
Ed.Poore7-Sep-06 0:57 
GeneralRe: TreeView Control in WinForms Pin
aka21097-Sep-06 18:31
aka21097-Sep-06 18:31 
QuestionDeleting records with child records? Pin
kbalias7-Sep-06 0:18
kbalias7-Sep-06 0:18 

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.