C++ unordered_map using a custom class type as the key

To be able to use std::unordered_map (or one of the other unordered associative containers) with a user-defined key-type, you need to define two things: A hash function; this must be a class that overrides operator() and calculates the hash value given an object of the key-type. One particularly straight-forward way of doing this is to … Read more

Compiling C++11 with g++

Flags (or compiler options) are nothing but ordinary command line arguments passed to the compiler executable. Assuming you are invoking g++ from the command line (terminal): $ g++ -std=c++11 your_file.cpp -o your_program or $ g++ -std=c++0x your_file.cpp -o your_program if the above doesn’t work.

Undefined reference to vtable

The GCC FAQ has an entry on it: The solution is to ensure that all virtual methods that are not pure are defined. Note that a destructor must be defined even if it is declared pure-virtual [class.dtor]/7. Therefore, you need to provide a definition for the virtual destructor: virtual ~CDasherModule() { }

usr/bin/ld: cannot find -l

To figure out what the linker is looking for, run it in verbose mode. For example, I encountered this issue while trying to compile MySQL with ZLIB support. I was receiving an error like this during compilation: /usr/bin/ld: cannot find -lzlib I did some Googl’ing and kept coming across different issues of the same kind … Read more

What is the difference between g++ and gcc?

gcc and g++ are compiler-drivers of the GNU Compiler Collection (which was once upon a time just the GNU C Compiler). Even though they automatically determine which backends (cc1 cc1plus …) to call depending on the file-type, unless overridden with -x language, they have some differences. The probably most important difference in their defaults is … Read more

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