fork download
  1.  
  2. #include<iostream>
  3. using namespace std;
  4. class Box
  5. {
  6. public:
  7. double length;
  8. double breadth;
  9. double height;
  10. void dimension(double l, double b, double h)
  11. {
  12. length = l;
  13. breadth = b;
  14. height = h;
  15. cout << "Length is " << length << "\n";
  16. cout << "Breadth is " << breadth << "\n";
  17. cout << "height is " << height << "\n";
  18. }
  19. double volume()
  20. {
  21. return length*breadth*height;
  22. }
  23. };
  24. int main()
  25. {
  26. Box b;
  27. b.dimension(5.5,2.0,1.1);
  28. cout << "Volume is "<< b.volume() << "\n";
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Length is 5.5
Breadth is 2
height is 1.1
Volume is 12.1