| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Auto string-length determination |
> Hmmm... Is it possible to make a function an operator?
In C++, yes.
> E.g. you could say
> int answer = 35 my_plus_function 35;
> and get answer to be 70...???
Hmm. C++ operators have to be standard operators (ie. you can't "make
up" your own, but have to chose from the inbuilt set). The normal
requirement is to do something like this:
string s = "hello" + " " + "world";
which is quite possible in C++ of you define both a conversion operator for
'char*' to 'string' and a '+' operator for type string.
class string
{
.
.
operator char const *();
string operator+(string const &);
.
.
};
There have been some very clever classes built up to take advantage of
conversion operators like this; one that comes to mind is the public domain
"val" class, which is a class that represents a polymorphic type,
with conversion operators to and from any of the C "basic" types;
int, long, float, char * etc.
--- MaltEd/2 1.0.b6
* Origin: Unique Computing Pty Limited (3:632/348)SEEN-BY: 50/99 620/243 623/630 632/103 107 271 348 360 601 635/503 544 728 SEEN-BY: 639/252 711/409 410 413 430 808 809 932 934 712/515 713/317 714/906 SEEN-BY: 800/1 @PATH: 632/348 360 50/99 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.