Computer Science, asked by gunnerkrrish, 11 months ago

Explain about pure virtual function with suitable example in C++ ?

Answers

Answered by shahbaz29
0

HEY MATE HERE IS YOUR ANSWER..

Explanation:

A pure virtual function (or abstract function) in C++ is a virtual function for which we don't have implementation, we only declare it. A pure virtual function is declared by assigning 0 in declaration. See the following example.

using namespace std;

using namespace std;   

using namespace std;   class Base

using namespace std;   class Base {

using namespace std;   class Base {    int x;

using namespace std;   class Base {    int x; public:

using namespace std;   class Base {    int x; public:     virtual void fun() = 0

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; }

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun()

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y;

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; }

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   int main(void)

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   int main(void) {

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   int main(void) {     Derived d;

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   int main(void) {     Derived d;     d.fun();

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   int main(void) {     Derived d;     d.fun();     return 0;

using namespace std;   class Base {    int x; public:     virtual void fun() = 0    int getX() { return x; } }  This class inherits from Base and implements fun() class Derived: public Base {     int y; public:     void fun() { cout << "fun() called"; } };   int main(void) {     Derived d;     d.fun();     return 0; }

HOPE IT HELPS

PLZ MARK AS BRAINLIEST AND

FOLLOW

Similar questions