Most voted "reference" questions
A reference is a value that allows a program to indirectly access a particular data, such as a variable or record in the memory of the computer or other storage device. The reference refers to the reference point.
Learn more…66 questions
Sort by count of
-
58
votes5
answers8000
viewsWhat is the difference between pointer and reference?
One of the first things I learned about Java is that this language "has no pointers, only references", followed by some generic statements about how the first is complex and the second is simpler.…
-
38
votes8
answers14487
viewsHow to create a copy of an object in Javascript?
I have an object called cachorro and would like to create and store a copy of that object. As objects, vectors, functions and regular expressions are considered objects I cannot make a copy just by…
-
19
votes4
answers955
viewsHow does Current function work?
For some time I always use the function current() in PHP, to get the first element of array (which is actually not its functionality, as it returns the current pointer on which the array is) and…
-
15
votes2
answers160
viewsWhat are "weak references"? When to use them?
In managed memory environments like Java, Python and Javascript, I’ve read something about weak references (WeakRef). I read that it had something to do with detecting the objects that can be…
terminology language-independent reference garbage-collectorasked 6 years, 4 months ago Jefferson Quesado 22,370 -
12
votes7
answers552
viewsWhat is the difference between these parameters (array) in these methods?
I see it a lot in methods class Exemplo { public function exemplo1(array $parameters = array()) { } public function exemplo2(array $parameters) { } public function exemplo3($parameters = array()) {…
-
8
votes3
answers2490
viewsWhat are the differences between pointer and reference in c++?
This question is a specific version for c++ of the question: What is the difference between pointer and reference? In practice, what are the differences between a pointer and a reference in C++? I…
-
8
votes2
answers391
viewsC++ (basic): for, references and syntax
My teacher presented this function to us: void escala(std::vector<double> &v, double fator) { for (auto &vi:v){ vi *= fator; } } It serves to multiply all the elements of a vector by a…
-
8
votes1
answer132
viewsIn Rust how does ampersand and asterisk work?
I came from Java recently and I’m studying Rust. Language has a totally different paradigm than I was used to, but it caught my attention. For never having messed with C or C++, sometimes I find…
-
7
votes1
answer88
viewsWhat is the advantage of PHP objects being passed by default references?
From PHP 5 an object variable no longer contains the object itself as a value. It contains an object identifier that allows the object’s "accessors" to find the real object. I recently went through…
-
6
votes2
answers1833
viewsCreate objects without reference C#
My question is, I have two instance of the class Parents, faths1 and fathers2, I created the 3 instance of the class Parents called fathers3 and said that it will be equal to instance fathers2,…
-
6
votes1
answer111
viewsWhat is type reference?
Was reading regarding the key word ref and I came across a warning that said not to confuse reference passage with type reference. No doubt this warning left me confused and awakened more doubts…
-
6
votes2
answers929
viewsWhat is the difference between expressions : "int a" and "const int& a" as C++ function arguments?
Let’s assume I have two functions: int soma_a(int a, int b){ return a + b; } and int soma_b(const int& a, const int& b){ return a + b; } What would be the difference between soma_a and…
-
5
votes1
answer115
viewsVariable reference in Javascript
To generate the following matrix: 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 Consider the following code for constructing a matrix with equal lines: var linha = [1, 2, 3, 4]; var matriz =…
-
5
votes2
answers214
viewsMake a reference variable point to another variable
I have the following question, for example: int a = 5; int b = 10; int & r = a; How do I use the reference variable r point to b and no longer to a? It is possible to do this?…
-
5
votes2
answers993
viewsOperation of variables by reference
I know that variables by reference in java serve to provide a location in memory of a certain object. However, how does this mechanism work? It is equal to the C language, where the reference types…
-
5
votes1
answer4125
viewsLatex - Quote from natbib without brackets
I wish that, in some places, the command " citep{XX}" makes the reference in the format [XX] and in others appears only XX. XX is the reference number (1, 2, 3, ....). Package definition:…
-
5
votes2
answers395
viewsBehavior of parameters in the class constructor in C#
I have a question regarding the behavior of the parameters passed to the constructor of a class, they are by default ref/out or value? Searching on the behavior of parameters in common methods they…
-
5
votes3
answers9397
viewsHow to pass arguments by reference in Python?
When I studied Pascal remember that my teacher explained that to pass an argument by reference it was necessary to put var in front of the variable, in the function/procedure parameters. Example:…
-
5
votes1
answer248
viewsWhat is the most appropriate way to store a reference in an object?
Suppose I want to create a library, where an object should receive another object added by the user and store it for later use. Ex: //header.h class Caixa{ private: Botao botoes[5]; public: void…
-
5
votes1
answer107
viewsIf everything in C# inherits from Object, why aren’t all types by reference?
If, for example, a struct type inherits from the class System.ValueType (who inherits from System.Object), why it, and the other types by value, are not allocated in the heap? By making a Boxing, we…
-
5
votes1
answer111
viewsSet does not remove duplicate objects
I have an array of objects and always to remove duplicate objects use the new Set(array), but this time did not work as expected. In the following example, it is easier to understand. I’m passing my…
-
4
votes1
answer199
viewsWhat is the reference of C++?
class Data { int d, m, a; public: void inic(int dd, int mm, int aa); void soma_ano(int n); void soma_mes(int n); void soma_dia(int n); }; void timewarp(Data& d) { } From what I understood the…
-
4
votes1
answer216
viewsHow does the reference to undeclared variables work in PHP?
In PHP, according to the manual, the reference of one variable serves for a variable to point to the same place where the other is in memory. I also saw that when we declare references to a variable…
-
4
votes1
answer94
viewsNested pointers and references
I’m having a doubt in the interpretation (the way I read my code) on pointer assignments in the C language. I did not understand the logic of the following assignments: "If i and j are whole…
-
4
votes2
answers137
viewsConstants of non-priminal types
In Java, constants are declared with sequences of Keywords static and final. When we have public static final int UM = 1; "makes sense to "call it constant, since its value cannot be changed. Now,…
-
4
votes1
answer58
viewsWhy does a function accept a reference instead of returning a value?
Consider the code snippet below: int num; printf("Enter a number: "); scanf("%d", &num); I understand that by passing &num to the second argument of scanf(), step the variable reference num,…
-
3
votes3
answers677
views -
3
votes1
answer65
viewsReference not found for object property
I developed a simple code of particles in codepen.io and its execution generates a log with the error: Uncaught TypeError: Cannot read property 'color' of undefined What is the reason for the error?…
-
3
votes1
answer377
viewsForeach behavior with variables by reference
I was doing some tests and I realized that the foreach has a strange behavior. Suppose I have the following array: $array = array('primeiro', 'segundo', 'terceiro'); When I run one foreach using a…
-
3
votes1
answer29901
viewsExcel formula to search part of the text in a table
I have a table of banks and codes in two columns. Ex.: Banco do brasil S/A 001 Banco do Estado do Rio Grande do Sul - Banrisul 041 Banco Santander do Brasil 033 Banco Mercantil do Brasil 208 Banco…
-
3
votes1
answer73
viewsAllocate memory with pointer or reference?
Is there any significant difference between these two methods? MyClass &ref = (*(new MyClass)); MyClass *ptr = (new MyClass);
-
3
votes2
answers66
viewsHow to put + of a domain in this code, different references
Hello, I have a code that works as a reference. That is if the visit comes from domain 01.com, it displays: WITH REFERENCE if it does not display: UNREFERENCED Code: <?php if…
-
2
votes0
answers461
viewsDynamically update ASMX web service reference
I have a C# application that consumes a webservice asmx (which is also developed in C#). Whenever I publish a new version of the webservice, I need to update the reference (of the webservice) in the…
-
2
votes2
answers189
viewsPassing by reference in C
In the case of language C, when we want to pass a variable by reference we need to pass its address to the function, I have a question in this case. Take the example: int main(){ int *a; *a = 5;…
-
2
votes2
answers340
viewsRefection return in C++
I cannot understand what the following function returns. int * begin(){ // return &this->data[0]; } Does this function return the address of a reference? I didn’t understand it very well.…
-
2
votes0
answers128
viewsReact-createRef() Api - this.child.Current is null
In order to allow mine parent component access values of my child component (Display), I started working with the createRef() API that came out in this patch 16.3. Following the example "Adding a…
-
2
votes2
answers250
viewsReferencing Python Variables
I’m learning programming on my own and no matter how I look online, I can’t understand exactly why the following reference doesn’t work as I imagine it would work. Let’s say I created a function to…
-
1
votes1
answer138
viewsWhere can I find the DLL microsoft.expression.Encoder.Devices?
I’m trying to develop a string instrument tuner in C#. I found a project called FFT Guitar Tunner, but I’ve been having some problems with his references. After all the only reference that keeps…
-
1
votes1
answer67
viewsHow to create a Weakhashset /Weakset in Java
The java.lang.ref package offers classes that model reference types in Java, such as Reference, Softreferece, Weakreference and Phantomreference. Still not familiar with these references in Java?…
-
1
votes3
answers241
viewshow to pass by value in Javascript
I have the following situation: let a=[{nome:"oi"},{nome:"xau"}] let b=Object.assign([], a) b[0].nome=5 console.log(b) //[{nome:5},{nome:xau}] console.log(a) //[{nome:5},{nome:xau}] A little while…
-
1
votes2
answers234
viewsWhy is the recursive function return not being used?
What happens when I call a function, recursively, without assigning its return to a variable? Why there is no need, in this case, to assign the function mergeSort explicitly the variable array?…
-
1
votes2
answers223
viewsAre parameters with vectors in Java always by reference?
I am aware that, in Java, any parameter passage of an object is by reference, already with primitive types, by value. However, I was left with doubt about the common vector. I don’t mean the class…
-
1
votes1
answer66
viewsHow to change the value of an entire argument passed as a reference in Julia
function muda_o_valor_do_inteiro!(x::Int64) x = 10 end a = 9 muda_o_valor_do_inteiro!(a) println(a) # a deveria possuir o valor 10 I have already understood that with vectors I can modify the value…
-
1
votes1
answer321
viewsStruct vector: Passage by reference in C
This code is from a simple register of people, containing code and name of the person. I am confused about the passage from the struct vector to the "insert procedure". When compiling, the program…
-
1
votes1
answer58
viewsIs it possible, in a function, to return the reference to an array index?
The idea is to have a function that receives a array and return the reference to an index of the same, for example: $list = ['a', 'b', 'c', 'd', 'e']; function ref(&list) { return &$list[3]…
-
1
votes1
answer56
viewsWhat is the purpose of the symbol "&" in the declaration of an object?
I noticed that some statements of variables/objects are used * for the statement (thus generating a pointer), but in some cases has the statement using &. const MyClass & my_class =…
-
1
votes2
answers57
viewsReference is making a variable change the value of another
What reason the value returning in the example below is 2 and not null? const Parametros = { Produto: { valor: null, peso: null, }, } const params = Parametros; params.Produto.valor = 2;…
-
0
votes0
answers294
viewsReference to objects
To what extent a reference to an object is exactly equal to it? I’ll explain my situation: Within a Adapter, i need to print a particular item in a list. The criterion for coloring that item is in…
-
0
votes1
answer17194
viewsUndefined object reference for an instance
"Undefined object reference for an object" instance I have this problem here in my project in Asp.net and I have not been able to move forward with it for a long time, please would you take a look…
-
0
votes1
answer316
viewsVisual Studio project losing references via git
When cloning a project, it is coming with some blank references, having to add manually. This problem only occurs with cloned projects, if you download the project as zip from github, it works…