Virtual Functions Accessed With Pointers

  • July 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Virtual Functions Accessed With Pointers as PDF for free.

More details

  • Words: 58
  • Pages: 2
Virtual Functions accessed with Pointers #include #include class Base { public: virtual void show() { cout<<"Base\n"; } }; class Derv1: public Base { public: void show() { cout<<"Derv1\n"; } }; class Derv2: public Base { public: void show() { cout<<"Derv2\n"; } }; int main() { Derv1 dv1; Derv2 dv2; Base* ptr; ptr=&dv1; ptr->show(); ptr=&dv2; ptr->show(); getch();

} ---------------------------------------

Related Documents

Virtual Functions
June 2020 3
Pointers
November 2019 36
Pointers
May 2020 9
Pointers
November 2019 22