3

I am in the process of reading "The C++ Programming Language 4th Edition" and I've gotten to the point where Bjarne is trying to explain concrete classes. His explanation is confusing me, and I cannot find any explanation online that satisfies me. I understand that abstract classes are classes that have at least one virtual function and that concrete classes are the opposite, but I can not wrap my head around concrete classes. The book "Programming Principles and Practice using C++" is saying that a concrete class is essentially a derived class, and an abstract class is a base class. Is this the correct interpretation? I have been trying to figure out this concept all day. Also, "a class that can be used to create objects is a concrete class". Does this mean that a class is concrete if I can do something like "myclass classobject1;", and I am not able to make objects with abstract classes?

  • 3
    This (https://stackoverflow.com/questions/2149207/what-is-the-difference-between-a-concrete-class-and-an-abstract-class) help? – user4581301 Jul 21 '17 at 23:43
  • @Ramon I've already viewed that question as well. After re-reading it, what I am getting from the answer is that a concrete class would be a class that inherited from an abstract class and made use of its virtual functions. Is this correct? –  Jul 21 '17 at 23:51
  • A concrete class is a class that is not abstract. It can be instantiated. – Retired Ninja Jul 21 '17 at 23:55

1 Answers1

4

Essentially, a concrete class is a class that implements an interface. An interface, such as an abstract class, defines how you can interact with an instance that implements that interface. You interact with an instance through member functions, so an interface typically declares virtual member functions that are meant to be overridden (implemented) by an implementing class (concrete class). If I have an abstract class Animal, it might have a virtual member function named speak. Animals all make different sounds, so the Animal interface does not know how to define that function. It will be up to the concrete classes, such as Dog, or Tiger, to define what actually happens when the speak function is invoked.

Joshua Jones
  • 1,364
  • 1
  • 9
  • 15
  • So basically the abstract class would be the base class that has the virtual functions, and the derived class that actually gives the virtual functions functionality is the concrete class? –  Jul 22 '17 at 00:23
  • 1
    While I used that scenario as an example, a concrete class does not necessarily need to derive from an abstract class. It is simply a class that defines the behavior of its member functions (interface) in full. – Joshua Jones Jul 22 '17 at 00:36