pass-by-value Questions
9
Solved
Consider the following code (I have purposefully written MyPoint to be a reference type for this example)
public class MyPoint
{
public int x;
public int y;
}
It is universally acknowledged (i...
Ott asked 13/4, 2015 at 13:25
6
Solved
I'm trying to understand the conceptual difference between call by reference, value, and name.
So I have the following pseudocode:
foo(a, b, c)
{
b =b++;
a = a++;
c = a + b*10
}
X=1;
Y=2;
Z=3...
Alfaro asked 5/4, 2013 at 0:15
16
Solved
Are PHP variables passed by value or by reference?
Metamorphosis asked 3/8, 2008 at 22:51
4
Solved
If I have a struct in swift with inside a class attribute and I copy the struct object, is the class attribute copied or passed by reference?
Separatist asked 8/12, 2016 at 17:39
11
Solved
Is it better in C++ to pass by value or pass by reference-to-const?
I am wondering which is better practice. I realize that pass by reference-to-const should provide for better performance in the p...
Martino asked 6/11, 2008 at 21:43
8
Solved
I am new to C++ programming, but I have experience in Java. I need guidance on how to pass objects to functions in C++.
Do I need to pass pointers, references, or non-pointer and non-reference val...
Alvinalvina asked 26/1, 2010 at 12:8
6
Solved
Does declaring something like the following
void foo(int x) { std::cout << "foo(int)" << std::endl; }
void foo(const int &x) { std::cout << "foo(const int &)" << st...
Kermis asked 28/3, 2011 at 21:29
5
I come from java world where I expect following things
int a = valueassignedbyfunction();
int b = a;
a = a + 1;
after this a is 1 greater than b. But in python the b automatically gets in...
Legalese asked 5/5, 2011 at 19:15
4
Solved
To reword the question in case someone types it into the search bar differently:
Is pass-by-value the same as making a deep copy, and is pass-by-reference the same as making a shallow copy?
If not...
Anarthrous asked 12/7, 2017 at 19:8
4
Solved
What does the Array.find method return; a specific copy of a found value or the reference of a found value?
Ire asked 21/6, 2020 at 10:17
1
Solved
When I'm passing a object by reference to a struct's new() method, and the struct will own the object, is it more conventional to:
pass the object by reference, and do to_owned() in the new()
clo...
Violetavioletta asked 19/5, 2020 at 19:9
2
Solved
#include<iostream>
#include<string>
template <typename T>
void swap(T a , T b)
{
T temp = a;
a = b;
b = temp;
}
template <typename T1>
void swap1(T1 a , T1 b)
{
T1 tem...
Burnett asked 20/4, 2020 at 14:48
1
Solved
I have a type throwing when copied:
struct A { A(const A&) { throw 1; } };
void doit(A)
{
}
int main()
{
A a;
doit(a);
return 0;
}
Is the exception thrown inside or outside of the...
Laryngotomy asked 25/3, 2020 at 20:50
6
Solved
Below is a snippet from the book C Programming Just the FAQs. Isn't this wrong as Arrays can never be passed by value?
VIII.6: How can you pass an array to a function by value?
Answer: An ar...
Plantaineater asked 23/1, 2011 at 14:58
8
Solved
I would like to emulate the pass-by-value behaviour in python. In other words, I would like to make absolutely sure that the function I write do not modify user supplied data.
One possible way is...
Kimbra asked 10/5, 2009 at 11:5
4
Solved
In C, the prototype for the absolute value function (that accepts a float) is
float fabsf( float );
Why doesn't this prototype accept a constant value, like this:
float fabsf( float const );
...
Wrangler asked 13/12, 2019 at 4:47
2
#include <iostream>
using namespace std;
class Car
{
public:
~Car() { cout << "Car is destructed." << endl; }
};
class Taxi :public Car
{
public:
~Taxi() {cout << "Taxi ...
Vendee asked 27/10, 2019 at 12:44
2
Solved
Assume I have this function
void foo() noexcept
{
// Safely noexcept code.
}
And then this class:
class Bar
{
Bar(const Bar&) { ... } // Is not noexcept, so might throw
// Non mova...
Bewhiskered asked 20/9, 2019 at 15:50
5
Solved
Is passing pointer argument, pass by value in C++? Since i see that any change to the pointer as such is not reflected outside the method. The changes i do by dereferencing the pointer is reflected...
Camber asked 13/12, 2010 at 7:3
13
Solved
Does JavaScript pass by references or pass by values?
Here is an example from JavaScript: The Good Parts. I am very confused about the my parameter for the rectangle function. It is actually ...
Fickle asked 27/10, 2012 at 21:50
8
Solved
1) When an array is passed as an argument to a method or function, is it passed by reference, or by value?
2) When assigning an array to a variable, is the new variable a reference to the original...
Quattlebaum asked 8/1, 2010 at 21:32
5
Solved
I found myself confused with the array and slice data types.
From Go docs, arrays are described as follows:
There are major differences between the ways arrays work in Go and C. In Go,
Arr...
Lalia asked 31/7, 2012 at 9:29
7
Solved
Since we have move semantics in C++, nowadays it is usual to do
void set_a(A a) { _a = std::move(a); }
The reasoning is that if a is an rvalue, the copy will be elided and there will be just one...
Mclaurin asked 10/1, 2014 at 2:56
1
Solved
Here's an obvious situation that must arise all the time for people:
struct Foundation {
var columns : [Column] = [Column(), Column()]
}
struct Column : CustomStringConvertible {
var cards = [Ca...
Giddy asked 2/1, 2019 at 23:7
2
Solved
This is more of a general question:
Is there any point in making a function parameter const if it is being passed by value?
In a code I am studying, I see a lot of the following:
void some_funct...
Watcher asked 18/12, 2018 at 14:7
© 2022 - 2024 — McMap. All rights reserved.