fork download
  1. #include <iostream>
  2. using namespace std;
  3. class data
  4. {
  5. protected:
  6. int r;
  7. public:
  8. void read()
  9. {
  10. cout<<"Enter the radius";
  11. cin>>r;
  12. }
  13. };
  14. class area: public data
  15. {
  16. private:
  17. float result;
  18. public:
  19. void compute()
  20. {
  21. result=3.14*r*r;
  22. }
  23. void display()
  24. {
  25. cout<<"the area of the circle is"<<result;
  26. }
  27. };
  28. int main()
  29. {
  30. area a;
  31. a.read();
  32. a.compute();
  33. a.display();
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5520KB
stdin
Standard input is empty
stdout
Enter the radiusthe area of the circle is1.24939e+19