Run ❯
Get your
own
website
❯
Run Code
Ctrl+Alt+R
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
#include
using namespace std; class Animal { public: virtual void animalSound() = 0; }; class Pig : public Animal { public: void animalSound() override { cout << "The pig says: wee wee\n"; } }; class Dog : public Animal { public: void animalSound() override { cout << "The dog says: bow wow\n"; } }; int main() { Pig myPig; Dog myDog; myPig.animalSound(); myDog.animalSound(); return 0; }
The pig says: wee wee
The dog says: bow wow