http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h
Chapter 9 // Exercise 4
Look at the headache-inducing last example of section 8.4. Indent it properly and explain the meaning of each construct. Note that the example does do anything meaningful; it is pure obfuscation.
This code is so confusing that even though it doesn't do anything it still made me question myself.
#include "stdafx.h"
#include "std_lib_facilities.h"
//just ew
struct X
{
//strangely returns 1 no matter what
void f(int x)
{
struct Y
{
int f() { return 1; }
int m;
};
int m;
m = x;
Y m2;
return f(m2.f());
}
int m;
//if m, return 3 if not return whatever is in m + 2
void g(int m)
{
if (m)
f(m + 2);
else
{
g(m + 2);
}
}
X() {} //default constructor for X struct
void m3() {} //define and declare m3, basically does nothing
void main()
{
X a;
a.f(2); //return 1
}
};
This code is so confusing that even though it doesn't do anything it still made me question myself.
No comments:
Post a Comment