fork download
  1.  
  2. //week-2(problem 2)_area_setget
  3.  
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. class Area{
  7. double x,y;
  8. public:
  9. void setDimension(double a,double b){
  10. x=a;
  11. y=b;
  12.  
  13. }
  14. double getArea(){
  15. return x*y;
  16. }
  17.  
  18. };
  19. int main(){
  20. double length, width;
  21. Area a1;
  22. cout<<"Enter length and width :";
  23. cin>>length>>width;
  24. a1.setDimension(length,width);
  25. cout<<"Area is :" <<a1.getArea();
  26. }
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Enter length and width :Area is :0