Answer to Question #269179 in C++ for Amit

Question #269179

WAP to show the working of abstract class by considering suitable example.


1
Expert's answer
2021-11-20T09:49:32-0500
#include<iostream>
using namespace std;
  
class AbstractClass
{
   int data;
public:
    virtual void pureFunction() = 0;
    int getData() { return data; }
};
  


class DerivedClass: public AbstractClass
{
    int x;
public:
    void pureFunction() { cout << "pureFunction() called"; }
};
  
int main(void)
{
    DerivedClass derived;
    derived.pureFunction();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS