Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I remember finding a piece of code online that completely abused operator overloading in C++ in order to draw pictures, something like:

int size = (I----I
            |    |
            I----I).area(); //returns 4

or

int v = (  o----o
          /    /1
         I----I |
         |    | 1
         I----I/ ).volume();

(The code here probably wouldn't compile, but the code was similar to here.)

Does anyone know where this website was? I'm looking all over the internet but can't find it. :(

share|improve this question

2 Answers

up vote 6 down vote accepted

They are called "Multi-Dimensional Analog Literals". I haven't actually tried them out, but the page claims that the code in fact conforms to standard C++. If that's the case, then it will probably compile and work.

While impressive, if I catch someone using them in production code I will (metaphorically!) beat them with a clue-stick. >:-)

share|improve this answer
YESS that's exactly the page I was looking for; thanksss! (I should use this in production code... :P) – Mehrdad Apr 10 '11 at 4:29
Lol, what triggered the edit with (metaphorically!)?! – Mehrdad Apr 10 '11 at 7:00
@Mehrdad: It's for the people who take everything too literally. :-) – In silico Apr 10 '11 at 20:37
lolll okay :) – Mehrdad Apr 10 '11 at 20:52
that page is gone!! – Jakob Weisblat Jul 19 '12 at 16:14

I haven't seen this particular bit of code before, but it sure looks like something that you might find in The International Obfuscated C Code Contest (http://www.ioccc.org/).

share|improve this answer
The International Obfuscated C Code Contest is, well, the International Obfuscated C Code Contest. – Eduardo León Jun 15 '11 at 18:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.