Skip to main content

All Questions

2 votes
4 answers
96 views

Iterating over an Array

I tried this block of code and it yields two different results public class PassArrayToFunction { public static void increase1(int[] arr){ for(int a: arr) a += 1; } ...
Cường's user avatar
-3 votes
1 answer
115 views

Is it better to pass a C++ object by reference than by value if it is in RAM? [closed]

There is a widespread opinion that in the C++ language it is better to pass an object to a function by reference than by value (thus supposedly reducing the number of copies). But what if this object ...
Dmitriy Sitnikov's user avatar
0 votes
3 answers
218 views

itk c++ function parameter passing

I am trying the simple act of writing a function (encapsulation) that calculates an histogram from the input via the itk ImageToHistogramFilter. While this works fine I do not seem to be able to get ...
Ichwerdennauchsonst's user avatar
1 vote
1 answer
161 views

Pass list of arguments to ggstatsplot function

I am using ggstatsplot to make lots of similar plots but the exact data or variable plotted will be different between each plot. I want to assign most of the (constant) arguments to a variable that I ...
Nathan Stutzman's user avatar
0 votes
2 answers
88 views

How to pass DOMDocument to Subroutine

I have a bunch of so called "structured data" from the German commercial register which comes in xml-files (one file always holds the data of one company). The data structure corresponds to ...
LuPi1801's user avatar
1 vote
3 answers
137 views

C program calling malloc results in bus error?

I have written this code to declare a pointer, p, and then dynamically allocate 4 bytes of memory for type int to then store some data in it. p should point to an address which holds the data 6 of ...
tekkyprograms's user avatar
0 votes
0 answers
42 views

Language C - function for Realloc struct pointer [duplicate]

I'm trying to build a function that realloc a struct pointer (which works as an arrays of structs), but it is not working out: I guess I'm not using the pointer reference correctly int the function ...
yuridesena's user avatar
1 vote
1 answer
65 views

Pass pointer to pointer behaves weird

I am solving Leetcode problem #94 for in-order traversal of a binary tree. I cannot understand why - when I use &cpy (currently commented) when calling helper() the program works correctly but not ...
Kingkong Jnr's user avatar
  • 1,158
0 votes
1 answer
335 views

How to get the name of the current environment THIS within a function

It looks like you can have one function pass data back transparently to a parent function with the assign operation. Example (Setup) calling = function() { a = 25; cat("\n ...CALLING....
mshaffer's user avatar
  • 1,003
0 votes
2 answers
64 views

Implications of pass-by-value vs pass-by-reference in C# [duplicate]

I was following along a tutorial online about C#. The tutorial talks about passing-by-reference vs passing-by-value. What I am confused about specifically is that since in C#, there is a distinction ...
user1234's user avatar
-2 votes
1 answer
200 views

Why should I copy the array element by element and then append to list instead of appending directly?

In the below code I am printing all the subsets using backtracking. I am printing the res_list at last. res_list = [[], [13], [12], [12, 13]] when I copy element by element of subset_list into a list ...
Mukesh Mahadev's user avatar
0 votes
0 answers
122 views

Which operator must be disabled to prevent passing by value

Of all the moove, copy, copy assign... operators Which must be deleted to avoid an object from being passed by value? For example. class MyClass { int val; }; As is the following can be declared: ...
Makogan's user avatar
  • 9,891
0 votes
2 answers
670 views

Passing variables of different types by reference as arguments to same variadic parameter

I've been struggling with golang's lack of optional parameters, so I have been using the closest workaround: variadics. Even though I got it working, it is messy attempting to pass multiple variable ...
Gabe Tucker's user avatar
0 votes
1 answer
74 views

PHP how come one element of the array is by reference and the other by value when passing a two element array as a by value parameter?

Can someone explain this strange behaviour I am witnessing in PHP 8.1.6? I guess the behaviour is according to standards, I just don't understand it. The function call has a parameter by value, yet ...
Roemer's user avatar
  • 1,272
0 votes
0 answers
337 views

How to pass template variadic arguments by reference in C++?

I want to get repeated inputs, therefore I made the function to get inputs with variety of types. template <typename InputType> void get_inputs(const std::string& placeholder, InputType& ...
gk2's user avatar
  • 67

15 30 50 per page
1
2 3 4 5
16