return-by-reference Questions
6
Solved
As I read in books and in the web, in C++ we can overload the "plus" or "minus" operators with these prototypes (as member functions of a class Money):
const Money operator +(const Money& m2) ...
Perk asked 31/1, 2014 at 16:42
6
Solved
I have a class called Object which stores some data.
I would like to return it by reference using a function like this:
Object& return_Object();
Then, in my code, I would call it like this...
Mathes asked 18/1, 2012 at 17:27
1
Solved
I was setting up a cache to draw some shapes. My approach was as following:
I created a class OrbitCacheManager.h that looked like this:
#ifndef OrbitCacheManager_h
#define OrbitCacheManager_h
#i...
Mcafee asked 4/12, 2018 at 15:16
2
Solved
I am trying to add a F#-style interface to a type, that has a byref return method.
Here's the code:
type IPool<'P, 'T when 'T: struct> =
abstract member GetReference: ITypedPointer<'P, '...
Lasandralasater asked 25/6, 2018 at 23:36
2
Solved
Is it possible in modern Fortran to return an array from a function with performance equivalent to having a subroutine fill an array passed as argument?
Consider e.g. as simple example
PROGRAM PR...
Fondly asked 21/6, 2016 at 14:22
9
Solved
While reading this explanation on lvalues and rvalues, these lines of code stuck out to me:
int& foo();
foo() = 42; // OK, foo() is an lvalue
I tried it in g++, but the compiler says "undefi...
Duhl asked 7/4, 2016 at 13:23
3
Solved
I am reasoning about the best approach to return references to objects created inside a method, like in the following situation:
class A{
public:
A(){}
~A(){}
};
class Foo{
public:
Foo(){}
...
Bushnell asked 12/3, 2015 at 13:46
5
Solved
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 a...
Urethra asked 22/10, 2011 at 19:40
7
Solved
How can I pass a variable by reference in scheme?
An example of the functionality I want:
(define foo
(lambda (&x)
(set! x 5)))
(define y 2)
(foo y)
(display y) ;outputs: 5
Also, is th...
Gravelblind asked 16/7, 2010 at 5:17
6
Solved
The following code invokes undefined behaviour.
int& foo()
{
int bar = 1234;
return bar;
}
g++ issues a warning:
warning: reference to local variable ‘bar’ returned [-Wreturn-local-addr...
Keciakeck asked 10/10, 2014 at 9:54
1
Solved
In the code snipped below, the compiler silently casts the return-by-copy function pointer into a return-by-const-reference std::function. When the std::function instance is called, a reference to ...
Dachau asked 25/4, 2014 at 5:40
5
Solved
Can you explain to me the difference between returning value, reference to value, and const reference to value?
Value:
Vector2D operator += (const Vector2D& vector)
{
this->x += vector.x;...
Collyrium asked 14/2, 2014 at 11:23
3
Solved
2013 Keynote: Chandler Carruth: Optimizing the Emergent Structures of C++
42:45
You don't need output parameters, we have value semantics in C++. ... Anytime you see someone arguing that nonono ...
Blitzkrieg asked 10/2, 2014 at 4:34
2
Solved
I have a function that returns an NSError object by reference:
NSData *foo(NSData *foo, NSError *__autoreleasing *outError);
This function uses an API that takes a pointer to storage for a CFErr...
Unterwalden asked 14/12, 2011 at 19:21
6
Solved
Suppose i have a function that returns an important result and several unimportant results. I declared it so that the unimportant results are returned by reference:
int CalculateStuff(int param1, ...
Frunze asked 17/10, 2011 at 11:56
1
Solved
I'm confused about how PHP variable references work. In the examples below, I want to be able to access the string hello either as $bar[0] or $barstack[0][0]. It would seem that passing the array b...
Gantt asked 7/10, 2011 at 18:40
3
Solved
This should be a fairly common question, but I haven't found a straightforward answer anywhere.
If I instantiate an object within a function in VB.NET and return it, does it return it by reference...
Lumpish asked 5/8, 2011 at 20:40
6
Solved
Whew, that was a long title.
Here's my problem. I've got a template class in C++ and I'm overloading the [] operator. I have both a const and a non-const version, with the non-const version return...
Meekins asked 11/8, 2010 at 13:37
3
Solved
I'm wanting to make sure I understand pass-by-value vs pass-by-reference properly. In particular, I'm looking at the prefix/postfix versions of the increment ++ operator for an object.
Let's suppo...
Tadpole asked 5/7, 2010 at 17:27
9
Solved
References in C++ are baffling me. :)
The basic idea is that I'm trying to return an object from a function. I'd like to do it without returning a pointer (because then I'd have to manually delete...
Havana asked 16/2, 2010 at 15:8
1
© 2022 - 2024 — McMap. All rights reserved.