CJCoding With Joseph

Interface With Two Pure Virtual Methods

An interface is an abstract class made only of pure virtual methods. A concrete subclass must implement EVERY one of them.

Create an abstract class Device with TWO pure virtual methods:
- string name() const (returns the device name)
- int power() const (returns watts)

Then create a concrete class Laptop that implements name() returning "Laptop" and power() returning 65.

Device cannot be instantiated; the runner uses a Device* to a Laptop and prints:
Laptop 65

Do NOT write a main function.

Expected Output:

Laptop 65
Topics:
Inheritance
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.