pass-by-value Questions
1
Solved
Consider this code (godbolt):
#include <iostream>
template<typename F> void call_by_val(F funct)
{
std::cout << "call_by_val(): ";
funct();
}
template<typename ...
Springlet asked 2/10 at 6:53
6
I have a problem with understanding the "pass-by-value" action of Java in the following example:
public class Numbers {
static int[] s_ccc = {7};
static int[] t_ccc = {7};
public static void ...
Ornas asked 31/1, 2009 at 12:33
3
When I'm passing a complex float(complex.h) from a c++ caller to a c library, the value does not pass correctly when running on a 32 bit power pc. I was using two different open source software lib...
Marlowe asked 24/3, 2016 at 16:3
6
Solved
A simple question for which I couldn't find the answer here.
What I understand is that while passing an argument to a function during call, e.g.
void myFunction(type myVariable)
{
}
void main()
...
Delinda asked 19/1, 2014 at 10:10
2
Solved
I am new to using pthread and also not that familiar with pointers to pointers. Could somebody perhaps explain why the second argument of pthread_join() is a void **. Why is it designed like this. ...
Busra asked 10/11, 2017 at 11:48
35
The primitive types (number, string, etc.) are passed by value. Still, objects are unknown because they can be both passed by value (in which case we consider that a variable holding an object is a...
Monoatomic asked 5/2, 2009 at 21:23
1
Solved
Consider:
#include <iostream>
using namespace std;
void Change(int arr[3]) {
for (int i = 0; i < 3; i++) {
arr[i] = 1;
}
}
int Test() {
int arr[3] = { 0, 0, 0 };
for (int i =...
Cleary asked 6/9, 2023 at 8:54
40
Solved
When copying an array in JavaScript to another array:
var arr1 = ['a','b','c'];
var arr2 = arr1;
arr2.push('d'); // Now, arr1 = ['a','b','c','d']
I realized that arr2 refers to the same array as a...
Cornwall asked 20/9, 2011 at 13:38
2
Solved
What is the meaning of Value semantics and Pointer semantics in Go? In this course, the author used to mention many times about above terms when explaining internals of arrays and slices which I co...
Hafler asked 10/7, 2018 at 11:44
6
Solved
Let's consider an object foo (which may be an int, a double, a custom struct, a class, whatever). My understanding is that passing foo by reference to a function (or just passing a pointer to foo) ...
Incogitant asked 21/10, 2016 at 21:26
1
Solved
I'm generating LLVM IR for JIT purposes, and I notice that LLVM's calling conventions don't seem to match the C calling conventions when aggregate values are involved. For instance, when I declare ...
Repine asked 11/9, 2016 at 16:4
7
Solved
If I pass a dataframe to a function and modify it inside the function, is it pass-by-value or pass-by-reference?
I run the following code
a = pd.DataFrame({'a':[1,2], 'b':[3,4]})
def letgo(...
Ironworker asked 11/8, 2016 at 11:59
7
Solved
So, I have some code, kind of like the following, to add a struct to a list of structs:
void barPush(BarList * list,Bar * bar)
{
// if there is no move to add, then we are done
if (bar == NULL) ...
Publicspirited asked 20/4, 2009 at 4:31
3
Solved
I create a function somewhere and I bind it to this so that I can use the parent block's meaning of this as the value of this within the function. For example:
var foo = function() {
// some stuf...
Machuca asked 14/4, 2018 at 18:50
5
Solved
In Go, I am trying to make a scramble slice function for my traveling salesman problem. While doing this I noticed when I started editing the slice I gave the scramble function was different every ...
Utas asked 12/10, 2016 at 8:15
6
Solved
How can I pass an object of a "MyClass" (C#) by Parameter-by-Value to a method? example:
MyClass obj = new MyClass();
MyClass.DontModify(obj); //Only use it!
Console.Writeline(obj.SomeIntProperty)...
Postpone asked 21/6, 2012 at 16:3
3
Solved
When building a simple object in go, what's the difference between these alternatives?
func NewGender(value string) Gender {
return Gender{strings.TrimSpace(value)}
}
func NewGender(value string...
Dogwood asked 25/8, 2015 at 15:41
10
Solved
I'm really new to Swift and I just read that classes are passed by reference and arrays/strings etc. are copied.
Is the pass by reference the same way as in Objective-C or Java wherein you actuall...
Mckenzie asked 8/12, 2014 at 18:6
5
Solved
I sent a reference to a bool object, and I modified it within a method. After the method finished its execution, the value of the bool outside the method was unchanged.
This leads me to believe tha...
Dufresne asked 29/9, 2009 at 20:17
8
Solved
class D {
public static void main(String args[]) {
Integer b2=128;
Integer b3=128;
System.out.println(b2==b3);
}
}
Output:
false
class D {
public static void main(String args[]) {
Int...
Pesek asked 9/11, 2009 at 9:58
8
Solved
In what circumstances should I prefer pass-by-reference? Pass-by-value?
Scar asked 13/2, 2011 at 19:29
18
What does it mean to say that a parameter is passed "by reference" or "by value"? How do such parameters differ?
Shaeshaef asked 17/12, 2008 at 1:49
13
Solved
How can I pass an integer by reference in Python?
I want to modify the value of a variable that I am passing to the function. I have read that everything in Python is pass by value, but ther...
Saad asked 1/3, 2013 at 0:45
9
Solved
In C#, I have always thought that non-primitive variables were passed by reference and primitive values passed by value.
So when passing to a method any non-primitive object, anything done to the ...
Lethalethal asked 3/1, 2012 at 6:19
7
I have a HashMap with some data. Looking at the following code...
HashMap<String, Double[]> map; //Already populated with data
Double[] results = map.get(key);
updateArray(results); //This ...
Pegram asked 20/8, 2014 at 15:1
1 Next >
© 2022 - 2024 — McMap. All rights reserved.