GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Nov-2006, 06:30
Gix Gix is offline
New Member
 
Join Date: Sep 2006
Posts: 21
Gix is on a distinguished road
Arrow

Overloading operator = in a managed class


Hi,

I am using Visual Studio .NET 2003.

I created a public __gc class PC (VS says it is a managed class because of this __gc = garbage collection) I still don't understand why I have to add all that but anyway I am trying to write a code for the operator = and it doesn't let me overload it with the usual
CPP / C++ / C Code:
void operator =(PC *Computer)

it says in managed classes use
CPP / C++ / C Code:
static op_<Name>

when I do this
CPP / C++ / C Code:
void static op_=
I get a new whole bunch of other errors.

Does anyone know how I can overload the = operator?

Thank you,

Gix
  #2  
Old 25-Nov-2006, 07:49
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,309
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Overloading operator = in a managed class


Quote:
Originally Posted by Gix
Visual Studio .NET 2003.
.
.
I am trying to write a code for the operator = .
.
.

it says in managed classes use
CPP / C++ / C Code:
static op_<Name>
.
.
.
Does anyone know how I can overload the = operator?


Use op_Assign

From msdn:

http://msdn2.microsoft.com/en-us/lib...00(vs.71).aspx

Regards,

Dave
  #3  
Old 25-Nov-2006, 08:06
Gix Gix is offline
New Member
 
Join Date: Sep 2006
Posts: 21
Gix is on a distinguished road

Re: Overloading operator = in a managed class


Thanks...

I did this but now I humbled upon a linker error!!!

Thank you anyway,

Gix
  #4  
Old 25-Nov-2006, 13:45
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Overloading operator = in a managed class


I moved the thread to the .NET Forum.
  #5  
Old 25-Nov-2006, 17:25
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,309
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Overloading operator = in a managed class


Quote:
Originally Posted by Gix
Thanks...

I did this but now I humbled upon a linker error!!!

Thank you anyway,

Gix

Post the code.
Tell us how you are compiling it. If it's from a GUI, what are the project settings? If it's from a command line, what are the options?

I used the __gc stuff in a previous version of .NET (just experimenting --- never did any serious development). With Visual C++ 2005 Express (the free download and the only thing that I can try it with now) I have to use a command-line option /clr:oldSyntax to make it go.


Regards,

Dave
  #6  
Old 26-Nov-2006, 04:34
Gix Gix is offline
New Member
 
Join Date: Sep 2006
Posts: 21
Gix is on a distinguished road

Re: Overloading operator = in a managed class


Thanks for all the help, I solved that problem but now I have posted my biggest one http://www.gidforums.com/t-12440.html

It'll be great if you can help again,

Gix
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Introduction to .NET LuciWiz .NET Forum 5 09-Aug-2007 04:53
Box Class, need help again :( TransformedBG C++ Forum 7 13-Nov-2006 15:11
C++ class -- Please help vnca_1 C++ Forum 3 14-Jun-2006 12:31
a tester class and then some. postage Java Forum 1 06-May-2006 15:48
Error C2146: syntax error : missing ',' before identifier 'C4' mattchew008 C++ Forum 2 19-Dec-2004 06:06

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:03.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.