Why should I initialize member variables in the order they’re declared in?

The reason is because they’re initialized in the order they’re declared in your class, not the order you initialize them in the constructor and it’s warning you that your constructor’s order won’t be used. This is to help prevent errors where the initialization of b depends on a or vice-versa. The reason for this ordering … Read more

How to detect whether there is a specific member variable in class?

Here is a solution simpler than Johannes Schaub – litb’s one. It requires C++11. #include <type_traits> template <typename T, typename = int> struct HasX : std::false_type { }; template <typename T> struct HasX <T, decltype((void) T::x, 0)> : std::true_type { }; Update: A quick example and the explanation on how this works. For these types: … Read more

make -j 8 g++: internal compiler error: Killed (program cc1plus)

Try running (just after the failure) dmesg. Do you see a line like this? Out of memory: Kill process 23747 (cc1plus) score 15 or sacrifice child Killed process 23747, UID 2243, (cc1plus) total-vm:214456kB, anon-rss:178936kB, file-rss:5908kB Most likely that is your problem. Running make -j 8 runs lots of process which use more memory. The problem … Read more

C++11 make_pair with specified template parameters doesn’t compile

This is not how std::make_pair is intended to be used; you are not supposed to explicitly specify the template arguments. The C++11 std::make_pair takes two arguments, of type T&& and U&&, where T and U are template type parameters. Effectively, it looks like this (ignoring the return type): template <typename T, typename U> [return type] … Read more

How to instruct GCC to stop after 5 errors?

The command-line option -fmax-errors=N directs the compiler to give up after N errors. This option is present in GCC 4.6 and later. The command-line option -Wfatal-errors directs the compiler to give up after one error. This option is present in GCC 4.0 and later. In both cases, warnings do not count toward the limit unless … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)