โ Back to Inheritance
Question 448
Interface With Two Pure Virtual Methods
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 classDevicewith TWO pure virtual methods: -string name() const(returns the device name) -int power() const(returns watts) Then create a concrete classLaptopthat implementsname()returning "Laptop" andpower()returning 65.Devicecannot be instantiated; the runner uses aDevice*to aLaptopand 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.