Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Object
- {
- public:
- virtual void BeginPlay();
- };
- class Actor : public Object
- {
- public:
- virtual void BeginPlay() override;
- };
- class Pawn : public Actor
- {
- public:
- virtual void BeginPlay() override;
- };
- int main()
- {
- Object* obj = new Object;
- obj->BeginPlay();
- Actor* act = new Actor;
- act->BeginPlay();
- Pawn* pwn = new Pawn;
- pwn->BeginPlay();
- delete obj;
- delete act;
- delete pwn;
- system("pause");
- }
- void Object::BeginPlay()
- {
- cout << "Object BeginPlay() called. \n";
- }
- void Actor::BeginPlay()
- {
- cout << "Actor BeginPlay() called. \n";
- // If we want to call the parent's function:
- Object::BeginPlay();
- }
- void Pawn::BeginPlay()
- {
- cout << "Pawn BeginPlay() called. \n";
- }
Advertisement
Add Comment
Please, Sign In to add comment