Mega Code Archive

 
Categories / C++ Tutorial / Class
 

Assign class object

#include <iostream> using std::cout; using std::endl; class Box {   public:     double length;     double width;     double height;     double volume() {       return length * width * height;     } }; int main() {   Box firstBox = { 80.0, 50.0, 40.0 };   Box secondBox = firstBox;   secondBox.length *= 1.1;   secondBox.width *= 1.1;   secondBox.height *= 1.1;   cout << secondBox.length        << secondBox.width        << secondBox.height        << endl;           cout << "Volume of second Box object is " << secondBox.volume()        << endl;   return 0; } 885544 Volume of second Box object is 212960