Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Call by value and reference?(C++)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Estraik
Expert Cheater
Reputation: 0

Joined: 05 Feb 2008
Posts: 128

PostPosted: Wed Sep 03, 2008 7:34 pm    Post subject: Call by value and reference?(C++) Reply with quote

I have a problem and I want to know if someone could explain to me in an easy way, what is in C++:


-Call by reference
and
-Call by value

I would really appreciate an explanation.

Thank you in advance.
Back to top
View user's profile Send private message
pkedpker
Master Cheater
Reputation: 1

Joined: 11 Oct 2006
Posts: 412

PostPosted: Wed Sep 03, 2008 7:42 pm    Post subject: Reply with quote

call by reference u get values changed from where you called it..

call by value u get values changed inside the call but nothing gets changed from where you called it.. only get back 1 return if its a function call.

Call by value: http://www.cpptutor.com/call-by-value-in-c++.htm
Call by reference: http://www.cpptutor.com/call-by-reference-in-c++.htm


reference means you passing the address of the datatype so it doesn't copy it.. it just modifies whats already there.


You gotta think about cheat engine memory view thing.

when u do

int aInt = 0;
you get 4 slots with 00's cuz int is 4 bytes (4 slots in memory).

when u call by value u just copy and make 4 more slots.. so you got 8 slots now. But you never access the old 4 slots after the copy is complete.. you just copy em over to new slots.

But by reference/pointer you access old slots you created without copying anything.. It's also much faster.. say you want to modify like 5 MB of memory would you copy it to make 10 MB of slots? or just use the current 5 MB of slots..

Yah that swap example teaches it all the best way possible.. how else can you get more then 1 value back without using pointers/reference

_________________
Hacks I made for kongregate.
Kongregate Universal Badge Hack: http://forum.cheatengine.org/viewtopic.php?p=4129411
Kongreate Auto Rating/Voter hack: http://forum.cheatengine.org/viewtopic.php?t=263576
Took a test lol
Back to top
View user's profile Send private message
Estraik
Expert Cheater
Reputation: 0

Joined: 05 Feb 2008
Posts: 128

PostPosted: Wed Sep 03, 2008 7:48 pm    Post subject: Reply with quote

Thanks a lot!!!!

That was what I was looking for, thank you so much.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites