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

Can redundant "using"s degrade performance

Just a performance question ... Let's say I have 5 classes and each of them have a reference to System.Data and a homegrown Library. The 5 classes in question are a part of a Class Library and will eventually be built and published up to some web…
cavillac
  • 1,311
  • 12
  • 22
6
votes
6 answers

What are some of the disadvantages of using a reference instead of a pointer?

Given a class "A" exists and is correct. What would be some of the negative results of using a reference to "A" instead of a pointer in a class "B". That is: // In Declaration File class A; class B { public: B(); ~B(); private: A&…
JadziaMD
  • 2,690
  • 5
  • 31
  • 42
6
votes
2 answers

C# foreach on IEnumerable vs. List - element modification persistent only for array - Why?

In C#, I have noticed that if I am running a foreach loop on a LINQ generated IEnumerable collection and try to modify the contents of each T element, my modifications are not persistent. On the other hand, if I apply the ToArray() or ToList()…
Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114
6
votes
4 answers

Printing a string to a temporary stream object in C++

I have a special type of ostringstream that I am trying to output text to as a temporary object but I'm having some trouble. To be clear, this is essentially what I want to do: ostringstream() << "PARTY DOWN!" << endl; Now before you say: "But…
Zack Schilling
  • 125
  • 1
  • 9
6
votes
5 answers

Are there any alternatives to implementing Clone in Java?

In my Java project, I have a vector of various types of Traders. These different types of traders are subclasses of the Trader class. Right now, I have a method that takes a Trader as an argument and stores it 50 or so times in the vector. I am…
Cory Walker
  • 4,809
  • 4
  • 28
  • 32
6
votes
5 answers

PHP and returning null references (revisited)

I've asked a question before, that essentially took the $null = null approach as a given, to returning a null reference in PHP. After some cursory Googling, I didn't turn up much; leaving me to assume that the aforementioned approach is the best…
Dan Lugg
  • 20,192
  • 19
  • 110
  • 174
6
votes
5 answers

How to return "not found" when return value is const reference

I have a problem that when I use something like this: const MyList& my_list = getListForThisRegion(/*region ID, ...*/); I dont know what to return when no value is found. My problem is that I would like to have a way to signal (when returning…
NoSenseEtAl
  • 28,205
  • 28
  • 128
  • 277
6
votes
2 answers

Why std::thread() passes arguments by value (and why the reason given by Dr. Stroustrup is incorrect)?

Quoting from The C++ Programming Language (by Bjarne Stroustrup), page 1213 The thread constructors are variadic templates (§28.6). This implies that to pass a reference to a thread constructor, we must use a reference wrapper (§33.5.1). For…
alex35833
  • 107
  • 6
6
votes
1 answer

Why can I have a const pair reference to a pair?

I found out by chance that I can have a const std::pair& reference to a std::pair: #include int main() { std::pair p{1,2}; const std::pair& ref_ok{p}; // why does this work? …
phinz
  • 1,225
  • 10
  • 21
6
votes
0 answers

Why adding a type annotation eliminates the borrow error?

I was learning Rust and all the references and borrowing stuff when I came across this weird case: fn main() { let mut n = 42u32; let ref1 = &mut n; let ref2 = ref1; // line 5 ref2; ref1; // line 8 } This…
6
votes
2 answers

Is there a good list of things left out of the Compact Framework?

I'm looking for a list of things left out of the Compact Framework, so I don't have to stumble over each one. For instance, I've just discovered the Message struct is not directly available. No big deal, but I spent an hour thinking I had done…
Newbie
6
votes
1 answer

Can you ignore specific versions of strongly named references?

I am doing some addons on a product which has strongly named references. If I select false in Specific Version, the program complains that the reference is installed already. Is there any possibility to ignore specific strongly named references?
Mark O'Grady
  • 1,144
  • 3
  • 14
  • 22
6
votes
3 answers

call F# dll in C#

How can I create F# dll and call it in C#? Thank you
Vahid_17m
6
votes
4 answers

Why r-value reference to pointer to const initialized with pointer to non-const doesn't create an temporary and bind it with it?

If we want to initialize an reference with an different type, we need to make it const (const type*) so that an temporary can be generated implicit and the reference binded to with. Alternativaly, we can use r-value references and achieve the same…
Manuel
  • 220
  • 3
  • 5
6
votes
1 answer

Using User Controls from Other Projects in ASP

I'm trying to re-use my ASP User Controls in other projects, and have hit upon a problem. I've read ScottGu's post on http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx and tried to follow his patterns but run-time the child controls of…
Tomas
  • 3,384
  • 2
  • 26
  • 28
1 2 3
99
100