can a pure virtual function has parameters?

yes, a PVF can have parameters.

virtual void playCard(Player enemyPlayer) = 0;

here = 0 (is not assigning), Simply we are informing to compiler that function will be pure and does not having any body(where its declared, in that class), but it can have parameter.

From the n4659 C++ standard

A pure virtual function need be defined only if called with, or as if
with (15.4), the qualified-id syntax (8.1).

class shape {
  point center;
  public:
  virtual void rotate(int) = 0; // pure virtual
  virtual void draw() = 0; // pure virtual
};

But there is another observation

A function declaration cannot provide both a pure-specifier and a
definition — end note ]

struct C {
   virtual void f() = 0 { };
};

Browse More Popular Posts

Leave a Comment