Hi,
I have two classes. Base and Derived. I want to call assign operator in
function f in Derived
In C++, I can do it like following -- void Derived::f(Base obj){ *this =
obj;}.
Now in c#, I write a function SetData(Base obj) to do it. But I am wondering
whether there is similar way (or standard way) in C# to do it.
Best Regards,
Michael zhang 3 2771
On May 14, 5:55 pm, zhanglr <zhan...@discussions.microsoft.comwrote:
Hi,
I have two classes. Base and Derived. I want to call assign operator in
function f in Derived
In C++, I can do it like following -- void Derived::f(Base obj){ *this =
obj;}.
Now in c#, I write a function SetData(Base obj) to do it. But I am wondering
whether there is similar way (or standard way) in C# to do it.
Best Regards,
Michael zhang
Hi Michael,
What do you want to achieve? Do you want the base class to point to
other class?
Moty
Hi,
I want to copy data from obj to this in void Derived::f(Base obj). I wonder
whether there is any standard way (override a function or operator) to do it.
Best Regards
Michael zhang
"Moty Michaely" wrote:
On May 14, 5:55 pm, zhanglr <zhan...@discussions.microsoft.comwrote:
Hi,
I have two classes. Base and Derived. I want to call assign operator in
function f in Derived
In C++, I can do it like following -- void Derived::f(Base obj){ *this =
obj;}.
Now in c#, I write a function SetData(Base obj) to do it. But I am wondering
whether there is similar way (or standard way) in C# to do it.
Best Regards,
Michael zhang
Hi Michael,
What do you want to achieve? Do you want the base class to point to
other class?
Moty
On May 14, 10:38 am, zhanglr <zhan...@discussions.microsoft.com>
wrote:
Hi,
I want to copy data from obj to this in void Derived::f(Base obj). I wonder
whether there is any standard way (override a function or operator) to do it.
Best Regards
Michael zhang
In C# you have two standard choices, but both of them involve doing
this when the derived object is first created:
1) A copy constructor: public DerivedClass(BaseClass baseData) { ... }
2) A copy constructor in combination with a cast overload, so that in
your code you can simply say:
BaseClass b = new BaseClass(...);
DerivedClass d = b; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rim |
last post by:
Hi,
I have been thinking about how to overload the assign operation '='.
In many cases, I wanted to provide users of my packages a natural
interface to the extended built-in types I created for...
|
by: Tony Johansson |
last post by:
Hello!
Assume you have a constructor for class AccountForStudent defined in this
way
AccountForStudent::AccountForStudent(Student s, double balance) : stud_(s),
balance_(balance)
{} //Here ...
|
by: ineedyourluvin1 |
last post by:
Hi, I would appreciate if someone could tell me what
I'm doing wrong ?
#include<iostream>
using namepace std ;
struct person{
char *firstname ;
int age ;
|
by: John |
last post by:
Ok. I'm not sure whether this is cool or perverted, I need second
opinion ;)
I define two classes as follows:
/********************************************/
public sealed class Dummy {...
|
by: Edward Diener |
last post by:
Since implement the assign operator for reference types eliminates the
ability to assign a reference object to a reference variable of the same
type or base class of that type, I assume that...
|
by: kotau |
last post by:
Hi,
I'm having trouble with something that would appear to have a simple
solution.
Here's a version of the code I'm working with:
const Item* p 0;
name::const_iterator i;
|
by: Avi |
last post by:
Hi
I am creating web application in which i want to assign by
default values to the property which i had created my own. In that one
of the property is of type color and i am unable to assign...
|
by: Chris Roth |
last post by:
vector<doublev1(5,1);
vector<doublev2;
v2 = v1; // 1
v2.assign(v1.begin(),v1.end()); // 2
Are 1 and 2 the same, or are their subtle differences between them.
Which is preferable, if either? ...
|
by: stephen b |
last post by:
Hi all, personally I'd love to be able to do something like this:
vector<intv;
v.assign(1, 2, 5, 9, 8, 7) etc
without having to manually add elements by doing v = 1, v = 2 ..
etc.
it would...
|
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...
|
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...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
|
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |