## Project Euler problem 2, optimized solution

https://projecteuler.net/problem=2 The obvious solution here is to check if each number in the sequence is divisible by 2 (n % 2 == 0), but »

https://projecteuler.net/problem=2 The obvious solution here is to check if each number in the sequence is divisible by 2 (n % 2 == 0), but »

Turns out they're usually implemented something like this: type& operator++() { ++iter; return *this; } type operator++(int) { type tmp = *this; ++*this; return tmp; } The second version »

Simple answer: Never, unless I'm overlooking something. Guaranteeing only one instance of something is exactly what static is designed for, or free functions in C++. Let's »