71.3k views
1 vote
Which of the following class represent an abstract class? (Points : 2) class Automobile {

void drive();
}
class Automobile {
void drive ()=0;
}
class Automobile {
virtual void drive ()=0;
}
class Automobile {
void drive (){}
}

User Gopard
by
6.5k points

1 Answer

2 votes

Answer:

class Automobile {

virtual void drive ()=0;

}

Step-by-step explanation:

In C++, an abstract class is one which cannot be instantiated. However it can be subclassed. A class containing a pure virtual function is considered an abstract class. A virtual function is preceded by the virtual keyword. For example:

virtual void drive();

In addition , if a virtual function is pure, it is indicated using ' = 0 ;' syntax.

For example:

virtual void drive() = 0;

Of the given options:

class Automobile {

virtual void drive ()=0;

}

represents an abstract class.

User Sfkleach
by
7.1k points