Reputation: 21
How do we know if a class in C++ is abstract just by looking at it's definition?
I mean, in Java, there would be an abstract keyword included in the class name. In C++, all we have is pure virtual functions...well, even then if a class derives an abstract base class (with pure virtual funcs) but fails to provide implementation for those functions (meaning that the derived class is also abstract), we wouldn't even know if the derived class is abstract just by looking at it as it would not contain any pure virtual functions and yet it's abstract.
So, what's the deal here?
Upvotes: 2
Views: 136
Reputation: 71
There is no way to tell from the definition whether or not a class is abstract, apart from looking for pure virtual functions like you said.
Upvotes: 2
Reputation: 711
In C++11 use is_abstract(), before there is the same function in boost.
Upvotes: 1
Reputation: 96
As such the standard doesn't use any special keywords for abstract classes in C++, the only way to know is the presence of at least one pure virtual function in the class.
Upvotes: 1