Advertisement

Operator overloading: is this possible?

Started by May 20, 2001 10:05 PM
1 comment, last by Mithrandir 23 years, 8 months ago
Every compiler I try it on says no, its not, but surely there must be some way?
  
stringclass operator+ ( const char* left, const char* right );
  
i want a binary operator to operate on two pointers to built in types, and the compiler complains about not having any classes in the parameters. i''ve fixed this by requiring the absolute left to be a stringclass like so (utilizing the char* constructor):
  
stringclass blah = stringclass( "blah" ) + "blah" + "blah" + "wo0t!";
  
but its kind of annoying sometimes. i don''t know, its not a major problem, its just a solution to some annoying semantics that I have encountered. =============================================== But as for me, hungry oblivion Devour me quick, accept my orison My earnest prayers Which do importune thee, With gloomy shade of thy still empery, To vail both me and my poesy
This is my signature. There are many like it, but this one is mine. My signature is my best friend. It is my life. I must master it as I must master my life. My signature, without me, is useless. Without my signature, I am useless.
You can''t add two constant char pointers, which is what "Blah" + "Blah" is.

Dire Wolf
www.digitalfiends.com
[email=direwolf@digitalfiends.com]Dire Wolf[/email]
www.digitalfiends.com
Advertisement
if you can do this, you can also overload operator+(int, int), then 1+1 can be any value for your sake, this is not acceptable

------------------------------
Dedicate to nobody, I''m nobody
------------------------------------------------------CCP is fascistic, they even banned www.sourceforge.net

This topic is closed to new replies.

Advertisement