I asked my friend if he can print from 1 to 1000 without using loops or coditionals after being intrigued by this thread:
Printing 1 to 1000 without loop or conditionals
He replied with this program.
#include <iostream>
using namespace std;
static int n = 1;
class f {
public:
f() {
cout << n++ << endl;
}
};
int main(int argc, char *argv[]) {
f n [1000];
}
Running the program outputs ok. But when I close the program on netbeans it seems to be still running and consuming memory. Is the program causing memory leak? And can someone explain how this small program works?