There have been multiple accounts created with the sole purpose of posting advertisement posts or replies containing unsolicited advertising.

Accounts which solely post advertisements, or persistently post them may be terminated.

ugo ,

You do have a terminology mismatch. In C++, an abstract class is a class with at least one pure virtual method.

Such classes cannot be instantiated, so they are useful only as base classes.

An interface is more of a concept than a thing.

Sure you can say that Iterable is an interface that provides the Next() and Prev() methods and you can say that Array is an Iterable because it inherits from Iterable (and then you override those methods to do the correct thing), and that’s one way to implement an interface in C++.

But you can also say that Iterable<T> is a class template that provides a Next() and Prev() methods that call the methods of the same name on the type that they wrap (CRTP aka static polymorphism).

Or you can say that an algorithm that scans a collection T forward requires the collection to have a Next() method by calling Next() on it.

And I can think of at least 2 other ways to define an interface that isn’t using abstract classes.

And even if using abstract classes, inheriting from them is definitely the least flexible way to use them to define an interface, because it doesn’t allow one to do something like mocking functionality in tests, because it’s not possible to redefine the class to be tested to inherit from the test interface implementation with mocked functionality, so one still needs something to the effect of dependency injection anyway.

So yeah, abstract class is very different from inheritance, and it’s also very different from interface, even though it relates to both.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • [email protected]
  • random
  • lifeLocal
  • goranko
  • All magazines