pass-by-reference

Passing a ref type in a property, does C# pass by value or ref

using c#, vs2008, winforms If i am passing a parameter via a property to a child form from a parent form, or infact via a property to any class, and the the paramater im passing in C# is a reference type created in the parent form, does it get passed as a ref or value by default ? Eg if i pass a dataset via a property. And if it does g...

CakePHP 1.2.6 / PHP5.2.12 Error in Array Loop in Assignment by Reference

I'm working on retrieving a stack of data and for some reason some of the data gets corrupted. For instance, I've got some Post models that each are related to Comment models (hasMany), and each of the Comment models belongsTo a User. When retrieving the data, here's what I get from the database for the comments: [Post] => Array ( ) [...

How to manipulate data in packed structures using a proxy class?

Hello all. i have a project wherein i am using System.Runtime.InteropServices to define a struct in the following manner such that it is packed to byte boundaries and ready to send to a serial port and from there to an embedded system. (business sensitive names have been removed) public class ControlCommandClass { [StructLayout(Layo...

PHP calling a function with variable amount of parameters.

So I've run into a bit of an issue. I know of a solution but it doesn't seem very clean and I'm wondering if there's a better one. I'm writing a MySQLi wrapper for running prepared statements. As it's a wrapper and is meant to be reused (dynamic) the amount of columns returned depends on the query and isn't static. The one solution to ...

C# Pass a property by reference

Is there anyway to pass the property of an Object by reference? I know I can pass the whole object but I want to specify a property of the object to set and check it's type so I know how to parse. Should I maybe take another approach (I cannot change the original object in anyway)? public class Foo{ public Foo(){} public int Age...

Call by reference in C++

What is actually passed in call by reference to a function? void foo(int &a,int &b) when I write foo(p,q) what is actually passed to the function. Is it the address of p and q? ...

Temporary non-const istream reference in constructor (C++)

It seems that a constructor that takes a non-const reference to an istream cannot be constructed with a temporary value in C++. #include <iostream> #include <sstream> using namespace std; class Bar { public: explicit Bar(std::istream& is) {} }; int main() { istringstream stream1("bar1"); Bar bar1(stream1); // OK on all platf...

Pass Variables By Reference in Javascript?

Hy i dont know if that is possible but i want to set a given variable in js per reference. What i want to do is, that each time i pass a string to the function addstring that the value of the textfield is added like += function addstring(string) { document.getElementById("string").value = string; // its a textfield } How can i d...

call c++ function with reference parameter from cli

The unmanaged function(pure c++): void fooC(float& result); I define the wrapper as (managed wrapper, c++\cli): void foo(float% result) //managed interface, need to pass result back to caller { fooC(???);//how to call unmanaged function? } how to pass reference parameter in the wrapper? ...

Can we overload a function based on only whether a parameter is a value or a reference?

I got the answer NO! Because passing by value and passing by reference looks identical to the caller. However, the code below compiles right class A { public: void f(int i) {} void f(int& i) {} }; But when I try to use it, there is compile error. int main () { A a; int i = 9; int& j = i; a.f(1); a.f(i); a.f(...

Is there a better way to pass by reference in Perl?

I am doing pass-by-reference like this: use strict; use warnings; sub repl { local *line = \$_[0]; our $line; $line = "new value"; } sub doRepl { my ($replFunc) = @_; my $foo = "old value"; $replFunc->($foo); print $foo; # prints "new value"; } doRepl(\&repl); Is there a cleaner way of doing it? Prototypes ...

fortran 90 user defined type, passing by value ?

I have an issue in Fortran 90. I have a user-defined type, and when I call one of the MPI subroutines the data looks to be passed by value (not address, as I thought it should). The output arguments aren't modified. It seems to be specific to the MPI calls. I tried the same thing in a simple test, and I can change the passed in values i...

Passing char * into fopen with C.

Hey there, I'm writing a program that passes data from a file into an array, but I'm having trouble with fopen (). It seems to work fine when I hardcode the file path into the parameters (eg fopen ("data/1.dat", "r");) but when I pass it as a pointer, it returns NULL. Note that line 142 will print "data/1.dat" if entered from command l...

Simulating pass by reference for an array reference (i.e. a reference to a reference) in Java

I was wondering, in java, is it possible to in anyway, simulate pass by reference for an array? Yes, I know the language doesn't support it, but is there anyway I can do it. Say, for example, I want to create a method that reverses the order of all the elements in an array. (I know that this code snippet isn't the best example, as the...

C# 4.0 'dynamic' doesn't set ref/out arguments

I'm experimenting with DynamicObject. One of the things I try to do is setting the values of ref/out arguments, as shown in the code below. However, I am not able to have the values of i and j in Main() set properly (even though they are set correctly in TryInvokeMember()). Does anyone know how to call a DynamicObject object with ref...

Bitmap manipulation as a referenced object

I am working with a Bitmap object that I add annotations or copyright material to the image and then return the modified bitmap. My problem is that the Bitmap won't hold the changes made to it as it moves along the chain. I am treating it as a reference type and would assume that as it gets passed to each class it would carry the changes...

Pass-by-Reference Error

I have a hook system setup... which is working on localhost... I put it live and get an error saying "Warning: Call-time pass-by-reference has been deprecated". Now, apparently the work around is to remove all "&" from your function calls, ie foo(&$me) to foo($me) and then in foo's function definition do "function foo(&$me)". However, ...

copy constructor by address

I have two copy constructors Foo(Foo &obj){ } Foo(Foo *obj){ } When will the second copy constructor will get called? ...

C# parameters by reference and .net garbage collection

I have been trying to figure out the intricacies of the .NET garbage collection system and I have a question related to C# reference parameters. If I understand correctly, variables defined in a method are stored on the stack and are not affected by garbage collection. So, in this example: public class Test { public Test() { } publ...

Delphi constants and references

I want to pass constant references to functions in delphi, so I am sure that the referenced object won't change and to save time and memory. So I want to declare a function like function foo(var const Value : Bar) : Boolean; however this is not allowed. I thought constant values would be automatically sent as references. However I fou...