undefined reference to ‘std::cout’

Compile the program with: as cout is present in the C++ standard library, which would need explicit linking with -lstdc++ when using gcc; g++ links the standard library by default. With gcc, (g++ should be preferred over gcc)

push_back vs emplace_back

In addition to what visitor said : The function void emplace_back(Type&& _Val) provided by MSCV10 is non conforming and redundant, because as you noted it is strictly equivalent to push_back(Type&& _Val). But the real C++0x form of emplace_back is really useful: void emplace_back(Args&&…); Instead of taking a value_type it takes a variadic list of arguments, so that means that you can now perfectly … Read more

Issue with std::stol – ‘std::invalid_argument’ what(): stol

I have an issue with std::stol. All answers I have found regarding to issues with std::stol or std::stoi are dealing with C++11 compiling / building. When I use std::stol() I get the following error: Any ideas? Building with gcc -std::C++11 works fine. Note: I think this is my first C++11 expression I use.

What exactly is std::atomic?

Each instantiation and full specialization of std::atomic<> represents a type that different threads can simultaneously operate on (their instances), without raising undefined behavior: Objects of atomic types are the only C++ objects that are free from data races; that is, if one thread writes to an atomic object while another thread reads from it, the behavior is … 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.

Why doesn’t C++ have a garbage collector?

Implicit garbage collection could have been added in, but it just didn’t make the cut. Probably due to not just implementation complications, but also due to people not being able to come to a general consensus fast enough. A quote from Bjarne Stroustrup himself: I had hoped that a garbage collector which could be optionally … Read more

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