62.3k views
2 votes
Which of the following declares an abstract method in an abstract C++ class? (Points : 2) public: void print();

public: void print() {}
public: virtual void print() {}
public: virtual void print()=0;

User Rothens
by
5.5k points

1 Answer

6 votes

Answer:

public: virtual void print()=0;

Step-by-step explanation:

An abstract class contains a pure virtual function. Pure virtual class cannot be instantiated but it can be subclassed and the subclass can provide an implementation of the function.

A virtual function declaration in the class is preceded by the virtual keyword. For example, virtual void print();

A pure virtual function declaration is followed by '=0;'

public: virtual void print()=0;

User Aric TenEyck
by
5.4k points