Is this class considered abstract because it only contains one virtual function?
I could still build an Animal object and use getFoodCost();
No. In C++, a "Abstract Class" is often a class having a single pure virtual function:
class Abstract {
public:
virtual void PureVirtual() = 0; // no implementation
};
class NotAbstract {
virtual void NotPureVirutal() {
// Some implementation
}
};
I assumed abstract classes couldn't be instantiated.
Yes, you are accurate.
This is due to the fact that abstract classes have functions that do not require implementation.
It has no mechanism to instantiate an object directly.
It refers to an abstract class using inheritance and pointers/references.
Does this imply that objects may contain virtual functions while still being considered abstract classes?
Yes.
Again, abstract classes are those with only virtual functions.
This is different from a regular virtual function.
As previously stated, pure virtual functions do not require implementation.
Regular virtual functions, on the other hand, must be associated with an implementation in order to be instantiated.