SunQuest
 
           C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old April 22nd, 2004, 09:03 PM
jwinsatt jwinsatt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 jwinsatt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
C++ Class base return value overload function?

Ok, this I can do:

my_class p;

p = 2;

I can make that work, what I want is this to work:

my_class p;
int i;
p = 4;
i = p;

That's not my ultimate goal of course, I could just say i = 4. But I would like for the above to work. Is it possible without doing something like this:

i = p.value;

I'm not worried about losing the ability to copy the object easily,that's not important. I could just make a func, and another class type within the class to handle the copy:

my_class b;
my_class p;

b.acceptdata = p.dumpdata();

Thanks in advance for any help.

Jon.

Reply With Quote
  #2  
Old April 23rd, 2004, 07:45 AM
jwinsatt jwinsatt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 2 jwinsatt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Nevermind, I found out.

Just so you know, there are things called conversion operators as follows

int myclass::operator int(){

return myclass.myint;

}

will return an integer when your class is used as an integer. Nice.

found this all at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_overloaded_operators.asp

thanks,

Jon.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > C++ Class base return value overload function?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway