问题
Example:
Iterators are pure abstractions: Anything that behaves like an iterator is an iterator.
What does it mean?
回答1:
An abstract class has at least one pure virtual function. This is standard C++ terminology.
Some people use the term pure abstract class to describe a class that has nothing but pure virtual functions (in other words, no data members and no concrete functions). This is equivalent to Java interfaces.
Now to your actual question:
Iterators are pure abstractions: Anything that behaves like an iterator is an iterator.
This has nothing to do with abstract classes (pure or otherwise). All it's saying is that anything that fulfils the iterator contract is an iterator. It doesn't even have to be a class (think pointers).
回答2:
Nothing. The C++ Standard states only that a), a class is abstract if it has at least one pure virtual function, direct or inherited, and b), you can't instantiate an abstract class directly. There's no such thing as a pure abstract class.
回答3:
I would think a pure abstract class is the C++ equivalent of an interface.
See here:
A pure Abstract class has only abstract member functions and no data or concrete member functions. In general, a pure abstract class is used to define an interface and is intended to be inherited by concrete classes. It's a way of forcing a contract between the class designer and the users of that class. The users of this class must declare a matching member function for the class to compile.
回答4:
An abstract class is a class with some functionality but some that needs to be implemented, whereas a pure abstract class has none of its functionality implemented.
This is a bit like an interface in other languages such as C# and Java.
A pure abstract class would serve the purpose of specifying a 'contract' that concretions of the pure abstract class must adhere to.
回答5:
Abstract Class *will atleast have one pure virtual function and can have data members.
Pure Abstract Class is just like an interface. Only pure virtual functions can be defined here. No data members or method definition can be done here.
For more information visit: (https://en.wikibooks.org/wiki/C%2B%2B_Programming/Classes/Abstract_Classes/Pure_Abstract_Classes)
回答6:
In C++ there is not pure abstract class. There are only abstract class and pure virtual function (function has been marked with = 0). Class with at least one pure virtual function becomes abstract. However pure virtual function can have implementation.
回答7:
In your example, you're talking about Iterators. In C++, and more specifically in the standard library, the term Iterators doesn't refer to a pure abstract class but to what are called concepts. Concepts are used with templates rather than with virtual/inheritance-based polymorphism. Currently (C++11), concepts are only defined in the library documentation, i.e. they do not (yet) exist as part of the C++ language itself. The standard library documents concepts, for example the "Iterator" concept, as a set of requirements for any type/object to be accepted as a type parameter of a template that wants to work with an "Iterator". A set of requirements is defined in terms of which expressions are valid on an object, regardless of its type. It's a form of duck-typing. For example, see : http://en.cppreference.com/w/cpp/concept/Iterator
来源:https://stackoverflow.com/questions/15253642/what-is-the-difference-between-abstract-class-and-pure-abstract-class-in-c