Update
[less_retarded_wiki.git] / cpp.md
blob326d431dfdef0d48cbde41496f87153e2ad82d64
1 # C++
3 C++ (also crippled C) is an [object-obsessed](oop.md) [joke](jokes.md) language based on [C](c.md) to which it adds only [capitalist](capitalist_software.md) features and [bloat](bloat.md), most notably [object obsession](oop.md). Most good programmers such as [Richard Stallman](rms.md) and [Linus Torvalds](linus_torvalds.md) agree that C++ is hilariously messy and also tragic in that it actually succeeded to become mainstream. The language creator [Bjarne Stroustrup](stroustrup.md) himself infamously admitted the language sucks but laughs at its critics because it became successful anyway -- indeed, in a retarded society only [shit](shit.md) can succeed. As someone once said, "C++ is not an increment, it is excrement". C++ specification has **over 2000 pages** :D
5 C++ source code files have the extensions `.cpp` or `.cc` (for "crippled C").
7 ## Examples
9 Here is our standardized **[divisor tree](divisor_tree.md)** program in C++:
11 ```
12 #include <iostream> // include standard I/O library
13 using namespace std;
15 // recursive function, prints divisor tree of x
16 void printDivisorTree(unsigned int x)
18   int a = -1, b = -1;
20   for (unsigned int i = 2; i <= x / 2; ++i) // find two closest divisors
21     if (x % i == 0)
22     {
23       a = i;
24       b = x / i;
26       if (b <= a)
27         break;
28     }
30   cout << '(';
32   if (a > 1)
33   {
34     printDivisorTree(a);
35     cout << ' ' << x << ' ';
36     printDivisorTree(b);
37   }
38   else
39     cout << x;
41   cout << ')';
44 int main()
46   while (1) // main loop, read numbers from the user
47   {
48     unsigned int number;
49     cout << "enter a number: " << flush;
50     cin >> number;
52     if (!cin.fail() && number < 1000)
53     {
54       printDivisorTree(number);
55       cout << endl;
56     }
57     else
58       break;
59   }
61   return 0;
63 ```