Wednesday, February 5, 2014

Programming Using Structures

Assignment: Programming Using Structures and Classes // Creating and victimization shockes #include <iostream> utilise std::cout; using std::endl; class CBox // Class definition at worldwide scope { public: bivalent m_Length; // Length of a box in inches persona m_Width; // Width of a box in inches double m_Height; // Height of a box in inches }; int main() { CBox box1; // hold in box1 of example CBox CBox box2; // Declare box2 of type CBox CBox box3; // Declare box3 of type CBox double boxVolume = 0.0; // Stores the people of a box double radicalVolumn = 0.0; // Stores the total volumn of the iii boxes box1.m_Height = 18.0; // throttle the values box1.m_Length = 78.0; // of the members of box1.m_Width = 24.0; // the fair game box1 box2.m_Height = box1.m_Height - 10; // Define box2 box2.m_Length = box1.m_Length/2.0; // members in box2.m_Width = 0.25*box1.m_Length; // terms of box1 // Define box3 box3.m_Height = box2.m_Height * 2; box3.m_Length = box2.m_Length + 5; box3.m_Width = 50; // Calculate volume of box1 boxVolume = box1.m_Height*box1.m_Length*box1.m_Width; cout << endl << Volume of box1 = << boxVolume; cout << endl << box2 has sides which total << box2.m_Height+ box2.m_Length+ box2.m_Width << inches.; cout << endl // video give away the size of a box in memory << A CBox intention occupies << sizeof box1 << bytes.; // Calculate the total volumn totalVolumn = boxVolume; // get the volumn of box1 totalVolumn += box2.m_Height*box2.m_Length*box2.m_Width; // Add the volumn of box2 totalVolumn += box3.m_Height*box3.m_Length*box3.m_Width; // Add the volumn of box3 cout << endl << The total volume for all three boxes = << totalVolumn; cout << endl; return 0; } o Under what circumstances must you use classes? When you fate to depict an object in the program, and ...If you want to get a beat essay, order i! t on our website: OrderEssay.net

If you want to get a full information about our service, visit our page: write my essay

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.