Questions tagged [reference]

A reference is a value that enables a program to indirectly access a particular datum, such as a variable or a record, in the computer's memory or in some other storage device.

A reference is a value that enables a program to indirectly access a particular datum, such as a variable or a record, in the computer's memory or in some other storage device. The reference is said to refer to the datum.

In some programming languages, copying a variable may be implemented as either a copy by value or a copy by reference. When it is copied by reference, a reference to the data will be assigned, and the underlying data is not copied. Often, object datatypes will be copied by reference by default (for example, in Java), while primitives will be copied by value.

A nice article on pass by reference

17086 questions
6
votes
1 answer

Externally defined markers don't appear in SVG

I'm trying to make the markers unified for a bunch of SVG images. My problem is that I cannot make external references in marker definitions work. It may be connected to question How to reference external svg file in svg correctly? but a link is…
Zsolt T
  • 71
  • 3
6
votes
2 answers

passing a pointer by reference in c++

I have a function where I'm passing in an iterator to a char * buffer (which is also a char *). The function needs to increment the iterator. Anyway, I found that a good method of passsing the iterator into the function is by passing the pointer…
Joe Lyga
  • 733
  • 2
  • 7
  • 17
6
votes
1 answer

Unsureness about passing EndPoint to Socket.ReceiveFrom()

If I do something like this: byte[] buffer = new byte[1024]; Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); IPEndPoint remote = new IPEndPoint(IPAddress.Parse("12.34.56.78"), 1337); sock.ReceiveFrom(buffer,…
haiyyu
  • 2,194
  • 6
  • 22
  • 34
6
votes
3 answers

String.Substring(): Copy, or Reference?

When a string is created using the SubString() method, is the resulting string a copy of the elements of the original string (so there are now 2 memory locations with the same information) or is it a reference to the existing memory location? If it…
3Pi
  • 1,814
  • 3
  • 19
  • 30
6
votes
3 answers

How can I call a function name defined in a literal string in perl?

If $name='name' why does $object_ref->$name work but not $object_ref->('name')?
JD.
  • 2,361
  • 6
  • 25
  • 38
6
votes
2 answers

Creating Rails Models Associations for has_many and belongs_to

Ok.. I'm new to Rails, and I know this has been asked before, but I'm still confused as to how to approach the following common problem. I can get the association to work, but having something magically work and starting rails with bad habits is not…
6
votes
2 answers

C/C++ API puzzle

This is an completely rewritten version of an earlier question; I think the first version omitted important details; this one provides all the context. I have a header of some C++ API. The API declares a few classes like this: class Foo { public: …
Mikhail Edoshin
  • 2,639
  • 16
  • 25
6
votes
4 answers

Javascript's assignment operation is to copy references?

The basic example: var b = 10; var c = b; b++; console.log(b,c); >> 11 10 c looks like a copy of b. But in another case: var x = {}; var y = x; x.abc = 10; console.log(x.abc, y.abc); >> 10 10 Why is the y not a copy of x, but a reference which…
Lai Yu-Hsuan
  • 27,509
  • 28
  • 97
  • 164
6
votes
2 answers

Refactoring shared code across multiple solutions

I have several Visual Studio solutions which shares a common project. Example: Solution of the common project - Common project Solution A - Common project - Custom project A Solution B - Common project - Custom project B And so…
Jason
  • 4,557
  • 5
  • 31
  • 40
6
votes
4 answers

Multiple names for the same variable in C++

Is it possible in C++ to refer to the same variable using different names without using the preprocessor? To achieve the same effect as this pseudocode struct vec3f { float[3] values; }; struct color : public vec3f { #define r values[0] …
wjd
  • 61
  • 1
  • 3
6
votes
2 answers

Clarification of References in C++

So I am attempting to learn C++ and I have come across something that puzzles me slightly. I have the code, int x = 0; int &y = x; cout << &x<< " " << x << " " << &y << " " <
daniel gratzer
  • 52,833
  • 11
  • 94
  • 134
6
votes
2 answers

Conditional References

Currently our .net code is not processor specific, but it depends on libraries (Oracle/ODP.Net) which are. We've found a solution where we edit the csproj file directly, and put the references in to item groups with a Condition clause based on our…
Justin
6
votes
5 answers

Reference variable in C++

Assume I have the following code snippet for GPoint, which has a copy constructor, assignment operator, and destructor. The same for GCircle and this has a function named GetCentre() which returns a copy of the Gpoint object(Centre). In main or…
Sal
  • 71
  • 2
6
votes
2 answers

Reference variable and virtual functions

I've found a strange behavior while using a reference variable. Here is class implementations: class Base { public: virtual void Method() = 0; }; class DerivedA : public Base { public: virtual void Method() {} } class…
Luca
  • 11,646
  • 11
  • 70
  • 125
6
votes
5 answers

Referencing static object created in one class throughout entire application

I have a java application that creates two static objects in a base class, these objects needs to references throughout classes in the program. public class Baseclass{ public static ClassA A = new ClassA(); public static ClassB B = new…
Chrizmo
  • 626
  • 2
  • 7
  • 18
1 2 3
99
100