• Forum
  • Lounge
  • Post your best C++ jokes, poems, stories

 
Post your best C++ jokes, poems, stories, etc.

Pages: 123... 6
They do this sort of thing in languages like Perl, Python and PHP.

Can we do it in C++?

For poems/stories:
Rules:
1. Has to be real C++. No made up data types, etc.
2. It has to be readable/make sense as a story, but operators can be included.

Points for:
1. Compiling. If it compiles, even if it has runtime errors, ten points.
2. If it doesn't have any runtime errors, 20 points.
3. If it actually does something (like output), 100 points.

Or just tell the best joke related to C++ that you know.
I like it :)
1
2
3
4
5
6
7
8
9
10
11
12
13
men()
{
   goto pub;
  pub:
   return pissed;
}

women()
{
   goto bathroom;
  bathroom:
   while (1) ;
}

This one is awesome.
I guess this could seem anti-Semitic, but it's not meant to. So sorry if it causes any offence but I don't expect it to.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class baby {
    public:
        int* foreskin;
        int rabbi();
};

int rabbi();

int main() {
bool circumcised=false;
mohel:
baby mohel;
rabbi(); /* --> */ if (circumcised=false) {
                       goto mohel;
                   }
return 0;
}

int rabbi() {
baby penis;
penis.foreskin;
delete penis.foreskin;
}
Last edited on
I don't know if this counts, but I found a quote which I found to be fuuny.

Anyway here it is.

Programming is a lot like sex, one mistake and you could be supporting it for the rest of your life.
Lol :P

It counts...

I remember one which I think Helios said a month or two ago;

"C++: Where your friends have access to your private members".
I thought that one was quite good :)
1. Use fprintf() ("fast printf") instead of printf().
2. ++i is faster than both i++ and i = i + 1.
3. void main(void) is faster than int main(void) or int main(int, char **) since no value needs to be returned to the OS.
4. Swapping with exclusive-or (a^=b^=a^=b swaps a and b) is faster than using a temporary. This works for all types (including structures), but not on all compilers. Some compilers may also give you a harmless warning.
5. Static storage duration objects are faster than automatic storage duration objects because the CPU doesn't have to set aside storage on the stack every time a function is called. Make your loop indexes global so that you can use them everywhere:
1
2
3
4
int i;
void func(void) { for (i = 0; i < 10; i++) ; /* ... */ }
void func2(void) { for (i = 0; i < 20; i++) ; /* ... */ }
/* ... */
6. Compilers often give more memory to arrays than you asked for. Here's how to check how big an array actually is (memset returns a null pointer if the size you passed to it is bigger than the size of the array you passed to it):
1
2
3
4
5
int arr[256];
size_t realsize;
for (realsize = 0; realsize <= SIZE_MAX; ++realsize)
        if (!memset(arr, 0, realsize)) break;
/* now you know that arr actually has realsize / sizeof (int) elements */
If you combine this with #5, your program will be faster in the long run (but this usually doesn't work for short programs).
Last edited on
Fast printf... :)

I don't get 2, though.
Compilers will optimize it for you I believe.
A very stupid compiler will attempt to save the previous value of i even if it's not used (not used: i++; used: i++ +1).
Making i++ and ++i equivalent is so stupid (I know how to do it) any compiler that can't do it deserves to be abolished.
chrisname
All of helios's examples are examples of really stupid things to do... The joke is that a lot of times people try to do stuff like that to try to speed things up and the like -- with the end result being a lot of poor code that is actually slower and more likely to break than the compiler would otherwise have produced.
Except that 2 is only true for pod-types.
That's true. However, who wrote it was thinking in C, not C++.
Ahh.

My friend told me a month or so ago about a programming language called LOLCODE. I saw you made a reference to it aswell, when someone was talking about writing an OS (which is one of my goals, but not for at least two or three years. And I'm talking a bootloader really). I hereby challenge all programmers and all hackerdom to create an OS in LOLCODE. If anyone does that; hats off to them.

There's a C# OS called SharpOS, and I think one in VB aswell. Maybe one that uses HTML as a runnable language, instead of Shell script or batch? It would have an inbuilt CSS and JavaScript Engine. Almost like a bootable web browser.

I think that might be what ChromeOS is about actually./..
LOLCODE became an old joke the day lolcats became an old joke.
The real achievement would be to write one in Brainfuck or Malbolge.
An OS written mainly in a functional language would be very interesting.
Last edited on
Lolcats? Old? NEVAR.

Anyway; Brainfuck? I just googled that; it looks pretty... interesting.

By "functional" language, do you mean like LISP?
Lisp, Scheme, Haskell, etc. Yes.
Why do programmers always mix up Halloween and Christmas?
Because Oct 31 equals Dec 25.
Lol

That gives me an idea... a conversion program.
Pages: 123... 6