Can I use an abstract base class for a strategy pattern or it a strategy pattern only suppose to be used an interface?
There isn’t any hard and fast rule with any pattern that you can’t use an abstract class instead of an interface - if using an interface causes a lot of code duplication, then I would definitely prefer the abstract class.
When using the Strategy pattern, all that matters is that any object you use to run code conforms to the same design. So long as you pass an object that is a type of “A” (abstract or interface), it should have the same set of functions just like all the other classes do.
They are interchangeable for use with the strategy pattern or anything else in your classes and functions. Your concrete classes can subclass an abstract class or implement an interface with the same effect. They can both use any helper functions written for the generalized class or interface.
That said, there are legitimate differences, some application related, some personal preference. Interfaces are raw signatures, this is both their strength and their weakness. Abstract classes allow you to create variables and functions which you can use in your subclasses; again that’s both a strength and a weakness. Writing code in your abstract class is really convenient, and qualitatively it’s no different than encapsulating code into a function.
While different programming challenges may push you in one direction or another, I have a strong personal preference for using interfaces. When I’m writing a function or a class, there are certain techniques that you just get used to and form best practices. You declare your variables. You organize your functions. Nothing earth shattering; however, classes based on abstract classes look like they violate these principles. You “never” declare a critical variable, you use a function that “doesn’t exist” (because they’re defined in the abstract class). This gets you used to looking at bad code, and is one more thing you have to deal with when you’re trying to hunt down problems (hmmm… I haven’t declared that variable… is that declared in the abstract class? I can’t remember.) Interfaces ensure that all your code stays together, because they don’t implement any functionality, there is never any hidden code. For me, this is a huge deal which saves hours / days when you’re debugging.