FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Overloading =

 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
jaker49



Joined: 19 Jun 2009
Posts: 4

PostPosted: Sun Jun 21, 2009 5:39 am    Post subject: Overloading = Reply with quote

In C++ it is possible to define the = operator

MyClass & MyClass::operator=( const MyClass& m ) {
MyData = m.MyData;
return *this;
}

Is there an equivalent in D?
Back to top
View user's profile Send private message
michaelp



Joined: 27 Jul 2008
Posts: 114

PostPosted: Sun Jun 21, 2009 10:25 am    Post subject: Reply with quote

http://digitalmars.com/d/2.0/operatoroverloading.html#Assignment
I'm assuming that's what you're looking for.
Back to top
View user's profile Send private message
jaker49



Joined: 19 Jun 2009
Posts: 4

PostPosted: Mon Jun 22, 2009 5:59 am    Post subject: Reply with quote

That was easy. Thank you.

Is there an equivalent to overloading operator<< (ostream & ).

In C++ it is

friend ostream & operator<<( ostream & os, const MyClass & Me ) {...}
Back to top
View user's profile Send private message
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Mon Jun 22, 2009 1:34 pm    Post subject: Reply with quote

opShl() for <<
opShr() for >>
opUShr() for >>>

http://digitalmars.com/d/2.0/operatoroverloading.html
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
doob



Joined: 06 Jan 2007
Posts: 367

PostPosted: Tue Jun 23, 2009 3:15 am    Post subject: Reply with quote

I think he is looking for "char[] toString()" in Object.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group