1
голосов
4ответов
1165 просмотров

Passing by Reference in PHP 5.x

I am studying for the Zend PHP5 Certification, everything looks good but i can not find real world examples for passing or returning variables my reference. It would be very nice, if someone has an example when to use this?

1
голосов
3ответов
150 просмотров

Assign a C++ out reference to something that was destroyed?

So I'm looking through some code, and I see this: class whatever { public: void SomeFunc(SomeClass& outVal) { outVal = m_q.front(); m_q.pop(); } private: std::queue<SomeClass> m_q; }; This doesn't seem like outVal would be a valid reference any more....

-1
голосов
2ответов
114 просмотров

some kind off variable problem within php class

I have this in my class When the second function is called php errors with wrong datatype and only variables can be past by reference. I don't know what they mean by that This code comes from php.net If the same code is outside the class it executes fine What am I doing wrong here, if I am wo...

0
голосов
7ответов
3091 просмотров

Java: Pass by reference / ListIterator.add()

Java doesn't pass variables by reference. In that case, how do data structures like ListIterator make changes to their corresponding list? Here is an example iterator I am writing: public class OdpIterator<E> implements ListIterator<E> { private OdpList<E> list; priva...

2
голосов
7ответов
4455 просмотров

Confusion between passing and modifying char pointers in C (reference vs. value)

I was wondering if you could help me out with a C string problem I don't quite understand. I have a function to which I send 3 char pointers. Within this function, the char pointers are shifted and modified correctly. However, when I return to the main function from which they are called, said fu...

4
голосов
2ответов
8590 просмотров

JNI Pass By Reference, Is it Possible?

I have a Java program that calls a C++ program to authenticate users. I would like the program to return either true or false, and if false, update a pointer to an error message variable that i then can grab from the Java program. Another explination: The native method would look something like...

3
голосов
5ответов
35582 просмотров

Understanding C# Events use of sender object

I am reasonably new to C# as a language (coming from a C++ background) and I am currently in the process of writing an application that makes use of an event driven API. Primarily this consists of registering event/response handlers and starting event monitors then dealing with these asychronous...

5
голосов
2ответов
798 просмотров

C++ DAL - Return Reference or Populate Passed In Reference

[EDIT 1 - added third pointer syntax (Thanks Alex)] Which method would you prefer for a DAL and why out of: Car& DAL::loadCar(int id) {} bool DAL::loadCar(int id, Car& car) {} Car* DAL::loadCar(int id) {} If unable to find the car first method returns null, second method returns false...

0
голосов
1ответов
125 просмотров

PHP/Joomla When to use references

i am reading http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_3_-_Using_the_Database $db =& JFactory::getDBO(); when do i need to use references? i tried the same thing without reference and it works. i thought objects are passed by reference (probably assignment a...

0
голосов
2ответов
298 просмотров

Unexpected behaviour with PHP array references

I'm using references to alter an array: foreach($uNewAppointments as &$newAppointment) { foreach($appointments as &$appointment) { if($appointment == $newAppointment){ $appointment['index'] = $counter; } } $newAppointment['index'] = $counter; ...

0
голосов
7ответов
334 просмотров

passing a block of memory from a function

I'm trying to figure out how to allocate a block of memory in a function and pass back a pointer to that block through one of the arguments. This is a C program. I seem to be having some trouble. Here's the code: void foo(char *ptr) { if (!(ptr = malloc(size))) printf("error"); ...

6
голосов
4ответов
6262 просмотров

In common-lisp, how do I modify part of a list parameter from within a function without changing the original list?

I'm trying to pass a list to a function in Lisp, and change the contents of that list within the function without affecting the original list. I've read that Lisp is pass-by-value, and it's true, but there is something else going on that I don't quite understand. For example, this code works as e...

1
голосов
1ответов
889 просмотров

Hibernate lost reference after calling save. Do you know why?

Take a look at the following classes (UNIdirectional @OneToMany) @Entity public class Team { private Integer id = -1; @Id @GeneratedValue public Integer getId() { return this.id; } private List<Player> playerList; @OneToMany @Cascade(CascadeType...

1
голосов
9ответов
1001 просмотров

Java method argument puzzle

I stumbled upon a very puzzling feature(?) of Java. It seems that using a "new" keyword to replace a method argument kind of shifts that object into a different scope: import java.util.ArrayList; public class Puzzle { public static void main(String[] args) { ArrayList<Integer&g...

3
голосов
8ответов
11952 просмотров

Pass parameter by reference between two Forms

I have two forms (Form1 and Form2). On Form1 there is a 'public int i' variable, which is set to value 1 in Form1 constructor. Then I open Form2 from Form1 with this code: Form2 f2 = new Form2(ref i); f2.ShowDialog(); The constructor of Form2 looks like this: public int i; public Form2(ref in...

0
голосов
5ответов
401 просмотров

C Variable Scope Specific Question

Here is a particular scenario that I have been unclear about (in terms of scope) for a long time. consider the code #include <stdio.h> typedef struct _t_t{ int x; int y; } t_t; typedef struct _s_t{ int a; int b; t_t t; }s_t; void test(s_t & s){ t_t x = {502...

0
голосов
5ответов
251 просмотров

C# passing Single as reference

I would like to have a method where the parameter could be Int32 or Single: void myMethod( ref object x ) { //...CodeHere } Since C# does not allow me to pass a specialization of object when using out or ref, the solution I found claimed that assigning the variable to a variable of the ty...

229
голосов
13ответов
128352 просмотров

Passing properties by reference in C#

I'm trying to do do the following: GetString( inputString, ref Client.WorkPhone) private void GetString(string inValue, ref string outValue) { if (!string.IsNullOrEmpty(inValue)) { outValue = inValue; } } This is giving me a compile error. I think its pretty clear ...

2
голосов
4ответов
2220 просмотров

PHP architecture, and pass-by-reference vs pass-by-value

Seeking suggestions from PHP architects! I'm not terribly familiar with PHP but have taken over maintenance of a large analytics package written in the language. The architecture is designed to read reported data into large key/value arrays, which are passed through various parsing modules to ex...

1
голосов
3ответов
403 просмотров

how to pass by reference a class var to a global var in PHP?

please tell me theres a way around this... $my_var = 'hello'; class Test{ private $my_var; private $my_internal_var = 'if you see this it works!'; function __construct(){ global $my_var; $this->my_var = &$my_var; } function get_my_var(){ re...

8
голосов
3ответов
1500 просмотров

C++ and QT4.5 - is passing a const int& overkill? Does pass by reference helps in signals/slots?

Two questions rolled into one here... I have a number of functions which are called multiple times per frame for a real-time video processing application. Taking advice about const and pass by reference, the functions have a signature somewhat like this void processSomething(const int& valu...

45
голосов
7ответов
60152 просмотров

Pass a string by reference in Javascript

I want to create a string and pass it by reference such that I can change a single variable and have that propagate to any other object that references it. Take this example: function Report(a, b) { this.ShowMe = function() { alert(a + " of " + b); } } var metric = new String("count"); var...

3
голосов
2ответов
1508 просмотров

Passing an object from F# into a C# method which takes it as an out parameter doesn't work?

One of the libraries I'm using defines this in C#: public ushort GetParameterSet(string name, out ParameterSet parameterSet) I'm trying to call this from F#: let parameterSet = new ParameterSet(); let retVal = currentPanel.GetParameterSet(name, ref parameterSet); However, even though the pa...

162
голосов
15ответов
184143 просмотров

Passing a String by Reference in Java?

I am used to doing the following in C: void main() { String zText = ""; fillString(zText); printf(zText); } void fillString(String zText) { zText += "foo"; } And the output is: foo However, in Java, this does not seem to work. I assume because the String object is copied in...

3
голосов
3ответов
179 просмотров

Long lists of pass-by-ref parameters versus wrapper types

I need to get three objects out of a function, my instinct is to create a new type to return the three refs. Or if the refs were the same type I could use an array. However pass-by-ref is easier: private void Mutate_AddNode_GetGenes(ref NeuronGene newNeuronGene, ref ConnectionGene newCo...

0
голосов
2ответов
197 просмотров

Javascript objects performance

I am unsure how javascript stores objects, and references them. So, I don't know if my plan will cause bad performance. Any insight would be appreciated. I have many divs on a website, and each has a unique id. I have an object constructor: function box_object(box_id){ this.the_box = docum...

2
голосов
1ответов
797 просмотров

Can we modify properties of object which is in Queue - C#?

I have used System.Collections.Queue and its object form_elements_queue if (form_elements_queue.Count > 0) queue_element = (RecordQueue)form_elements_queue.Peek(); I'm modifying the queue_element like below, queue_element.Children--; RecordQueue is my custom Type which I Enqueue i...

1
голосов
2ответов
2685 просмотров

Better way for pass by reference from C# to C++?

I have a 3rd party collection of .h files along with the .lib files that go with them. I am wrapping those native C++ files with a C++/CLI wrapper and making final calls from C#. I have an issue when I call methods that expect a reference to be passed in where the value is not getting changed i...

7
голосов
2ответов
4395 просмотров

PHP pass by reference in recursive function not working

I have two functions that I'm using to add or remove slashes from a deeply nested object/array combo. The first "level" of the array is always an object, but some of its properties may be arrays or objects. Here are my two functions: function objSlash( &$obj, $add=true ) { foreach ( $ob...

22
голосов
4ответов
21861 просмотров

How to pass a variable by value to an anonymous javascript function?

The Objective I want to dynamically assign event handlers to some divs on pages throughout a site. My Method Im using jQuery to bind anonymous functions as handlers for selected div events. The Problem The code iterates an array of div names and associated urls. The div name is used to set ...