| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > C++ Class base return value overload function? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|