g++ “because the following virtual functions are pure” with abstract base class

Your SortedContainerImpl class has two separate Container base classes. One is virtual (via the SortedContainer class) and the other is non-virtual (via the ContainerImpl class). SortedContainerImpl has concrete implementations of Container::get_size() and Container::get(int) for the base that comes in from ContainerImpl, but not for the virtual base that comes in via SortedContainer. One way to … Read more

How to alphabetically sort strings?

You could use std::set or std::multiset (if you will allow repeated items) of strings, and it will keep the items sorted automatically (you could even change the sorting criteria if you want). input: Gerardo Carlos Kamilo Angel Bosco output:

The program can’t start because libgcc_s_dw2-1.dll is missing

I believe this is a MinGW/gcc compiler issue, rather than a Microsoft Visual Studio setup. The libgcc_s_dw2-1.dll should be in the compiler’s bin directory. You can add this directory to your PATH environment variable for runtime linking, or you can avoid the problem by adding “-static-libgcc -static-libstdc++” to your compiler flags. If you plan to distribute the … Read more

What is object slicing?

“Slicing” is where you assign an object of a derived class to an instance of a base class, thereby losing part of the information – some of it is “sliced” away. For example, So an object of type B has two data members, foo and bar. Then if you were to write this: Then the information in b about member bar is lost in a.

What is the difference between .cc and .cpp file suffix?

Conventions. Historically, the suffix for a C++ source file was .C. This caused a few problems the first time C++ was ported to a system where case wasn’t significant in the filename. Different users adopted different solutions: .cc, .cpp, .cxx and possibly others. Today, outside of the Unix world, it’s mostly .cpp. Unix seems to use .cc more often. For headers, the situation … Read more