1

For a bass class that has a virtual function usually call "a polymorphic base class". In this case Car class

class Car
{
 virtual void drive(){std::cout << "drive right";}
};

class EuropeCar: public Car
{
 void drive(){std::cout << "drive left";}
}

Is polymorphic base class a general slang such as pure abstract class or a part of C++ standard?

Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147

3 Answers3

7

The standard mentions polymorphic class specifically, for example, in 10.3.1:

Virtual functions support dynamic binding and object-oriented programming. A class that declares or inherits a virtual function is called a polymorphic class.

It also talks about abstract classes and pure virtual functions, like in 10.4.2:

An abstract class is a class that can be used only as a base class of some other class; no objects of an abstract class can be created except as subobjects of a class derived from it. A class is abstract if it has at least one pure virtual function.

There is no specific mention of a pure abstract class (or pure virtual class), only pure virtual functions.

N.B: This is based off the draft standard, n3376.

Yuushi
  • 25,132
  • 7
  • 63
  • 81
5

The C++14 standard does define the term "polymorphic class" (10.3/1):

A class that declares or inherits a virtual function is called a polymorphic class.

But it doesn't use the term "polymorphic base class".

Vaughn Cato
  • 63,448
  • 5
  • 82
  • 132
1

I'm not sure about "slang" but a pure abstract class in C++ has a definite meaning.

A pure abstract base class in C++ has only abstract member functions (meaning they are all declared virtual <return_type> <func_name>() = 0) and no data or concrete member functions .

A polymorphic base class here is a much looser term in comparison.

shafeen
  • 2,431
  • 18
  • 23
  • they are simply words to convey a well known idea concisely, if you said "I made a pure abstract base class" I automatically know that your class only has abstract member functions and no data or concrete data members – shafeen Feb 16 '16 at 03:13
  • Have to disagree... an *"abstract base class"* is defined by the Standard as any sporting one or more pure virtual functions. "pure" has no special formal meaning for classes, so seems a tautological reference to the same type of function. That C++ Standard definition is no way excludes *"data or concrete member functions"* the way this answer suggests. – Tony Delroy Feb 16 '16 at 03:49
  • I was describing a "pure abstract base class" not an abstract base class – shafeen Feb 16 '16 at 03:50
  • @shafeen: I know... as I said, describing classes as "pure" is not C++ Standard terminology, and will likely be dismissed by other C++ programmers as a tautological reference to the pure virtual function(s) an abstract class necessarily contains. – Tony Delroy Feb 16 '16 at 03:53
  • true, I wasn't claiming to cite C++ standard terminology, simply explaining what a commonly used term may mean from another fellow C++ programmer – shafeen Feb 16 '16 at 03:56
  • I understand - just saying it's contentious - some programmers will use the term the way you suggest, and others will think you're making a poorly-phrased mention of abstract classes. See [here](http://stackoverflow.com/questions/15253642/what-is-the-difference-between-abstract-class-and-pure-abstract-class-in-c) for a question that shows how the term is not universally understood. – Tony Delroy Feb 16 '16 at 04:00