Raised This Month: $51 Target: $400
 12% 

Compiler throwing error with &Handle when newdecls are required


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
infi
Member
Join Date: Sep 2013
Old 04-27-2017 , 07:24   Compiler throwing error with &Handle when newdecls are required
Reply With Quote #1

Hello,

I'm slowly just rewriting parts of my plugin that I did a while ago in the new syntax, and it doesn't seem to sit well with TF2Items_OnGiveNamedItem due to the last parameter. How do you pass a reference in the new syntax? Thanks.
infi is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 04-27-2017 , 07:59   Re: Compiler throwing error with &Handle when newdecls are required
Reply With Quote #2

PHP Code:
Handle &handle 
__________________
WildCard65 is offline
wwahgnerbp
Member
Join Date: Mar 2013
Location: Earth, Solar System
Old 04-28-2017 , 16:51   Re: Compiler throwing error with &Handle when newdecls are required
Reply With Quote #3

Quote:
Originally Posted by WildCard65 View Post
PHP Code:
Handle &handle 
by the way I have a noob question. What's the function of "&" there?
wwahgnerbp is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 04-28-2017 , 17:20   Re: Compiler throwing error with &Handle when newdecls are required
Reply With Quote #4

It means the function parameter is passed by reference, not value.

PHP Code:
ByRefExample(int &i) { 2; }
foo() {
  
int x 1;
  
ByRefExample(x);
  
PrintToConsole("%d"x);

This would print 2. If it weren't passed by reference, then x would still be 1.
Fyren is offline
wwahgnerbp
Member
Join Date: Mar 2013
Location: Earth, Solar System
Old 04-28-2017 , 17:44   Re: Compiler throwing error with &Handle when newdecls are required
Reply With Quote #5

Quote:
Originally Posted by Fyren View Post
It means the function parameter is passed by reference, not value.

PHP Code:
ByRefExample(int &i) { 2; }
foo() {
  
int x 1;
  
ByRefExample(x);
  
PrintToConsole("%d"x);

This would print 2. If it weren't passed by reference, then x would still be 1.
Thank you.
wwahgnerbp is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 06:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode