473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Getting reference to left argument of assignment operator

Anyone know of any way to get a reference to the argument to the left (lvalue
I believe it is called) of the assignment operator? I realize you can't
overload the assignment operator in C#, but maybe someone might know some
creative solution using unsafe or interoperable C++ code.
Jun 27 '08 #1
2 1004
Just make a void method that acts upon the result object.

So in code, the following:

x = Foobar(2, 3, 4);

Becomes:

x.Foobar(2, 3, 4);

Then Foobar can reference 'this' or 'me' depending on your language.

"Mike" wrote:
Anyone know of any way to get a reference to the argument to the left (lvalue
I believe it is called) of the assignment operator? I realize you can't
overload the assignment operator in C#, but maybe someone might know some
creative solution using unsafe or interoperable C++ code.
Jun 27 '08 #2
Thanks for the response, but this is not quite what I'm looking for. I'm
trying to do an implicit cast from one of the built in .Net types to one of
my custom types, but I don't want to have to re-instantiate my custom type
when I do the cast. I want a reference to the object I'm assigning to.

For example:
static public implicit operator RomanNumeral(int value)
{
return new RomanNumeral(value);
}

Rather than new up a RomanNumeral object, I want a reference to the
RomanNumeral I'm assigning to. I'm sure there's no "normal" way to do this.
I'm looking to be atypical.

Thanks, Mike

"Family Tree Mike" wrote:
Just make a void method that acts upon the result object.

So in code, the following:

x = Foobar(2, 3, 4);

Becomes:

x.Foobar(2, 3, 4);

Then Foobar can reference 'this' or 'me' depending on your language.

"Mike" wrote:
Anyone know of any way to get a reference to the argument to the left (lvalue
I believe it is called) of the assignment operator? I realize you can't
overload the assignment operator in C#, but maybe someone might know some
creative solution using unsafe or interoperable C++ code.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Basil | last post by:
Hello. Compiler BCB60. There is a simple example: class a1 { int v; public: a1 ():v (0) {} a1 (int v1):v (v1) {}
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
10
by: Tony Johansson | last post by:
Hello Experts!! This class template and main works perfectly fine. I have this class template called Handle that has a pointer declared as T* body; As you can see I have a reference counter in...
8
by: junw2000 | last post by:
Hi, My textbook says that: "Once defined, a reference cannot be reassigned because it is an alias to its target. What happens when you try to reassign a reference turns out to be the assignment...
8
by: toton | last post by:
HI, One more small doubt from today's mail. I have certain function which returns a pointer (sometimes a const pointer from a const member function). And certain member function needs reference...
0
by: mseeger | last post by:
My concrete problem is this (it is a bit special, but there may be other instances of it): I'd like to create a class for vectors (say: Vector), exporting math. methods, say v.foo(...). I'd like...
3
by: josh | last post by:
Why if I use: Array *Array::operator=( const Array *right ) { if ( right != this ) { // check for self-assignment // for arrays of different sizes, deallocate original // left side array,...
1
by: subramanian100in | last post by:
consider template<typename TTest { // ... }; We can have a pointer type as argument to a template class. For example, we can have, int x = 100; Test<int*obj(&x); // assuming a suitable ctor...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.