Class Mapping Error: ‘T’ must be a non-abstract type with a public parameterless constructor

The problem is that you’re trying to use the T from SqlReaderBase as the type argument for MapperBase – but you don’t have any constraints on that T. Try changing your SqlReaderBase declaration to this: public abstract class SqlReaderBase<T> : ConnectionProvider where T : new() Here’s a shorter example which demonstrates the same issue: class … Read more

When to use mixins and when to use interfaces in Dart?

Mixins is all about how a class does what it does, it’s inheriting and sharing concrete implementation. Interfaces is all about what a class is, it is the abstract signature and promises that the class must satisfy. It’s a type. Take a class that is implemented as class MyList<T> extends Something with ListMixin<T> …. You … Read more

When do I have to use interfaces instead of abstract classes? [duplicate]

From Java How to Program about abstract classes: Because they’re used only as superclasses in inheritance hierarchies, we refer to them as abstract superclasses. These classes cannot be used to instantiate objects, because abstract classes are incomplete. Subclasses must declare the “missing pieces” to become “concrete” classes, from which you can instantiate objects. Otherwise, these … Read more

Abstract classes vs. interfaces vs. mixins

Abstract Class An abstract class is a class that is not designed to be instantiated. Abstract classes can have no implementation, some implementation, or all implementation. Abstract classes are designed to allow its subclasses share a common (default) implementation. A (pseudocoded) example of an abstract class would be something like this abstract class Shape { … Read more

UnsupportedOperationException at java.util.AbstractList.add

You’re using Arrays.asList() to create the lists in the Map here: itemStockMap.put(item.getInfo(), Arrays.asList(item.getStock())); This method returns a non-resizable List backed by the array. From that method’s documentation: Returns a fixed-size list backed by the specified array. (Changes to the returned list “write through” to the array.) In order to use a resizable List (and actually … Read more

Why can’t we declare a std::vector?

You can’t instantiate abstract classes, thus a vector of abstract classes can’t work. You can however use a vector of pointers to abstract classes: std::vector<IFunnyInterface*> ifVec; This also allows you to actually use polymorphic behaviour – even if the class wasn’t abstract, storing by value would lead to the problem of object slicing.