Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can someone read this code/ and describe to me with // on the lines what is being achieved here. Thats all. Thank you in advance/
Can someone read this code/ and describe to me with // on the lines what is being achieved here. Thats all. Thank you in advance/ I also apologize as I'm not sure if this is too big of a question to ask here. Either way thank you.
Sub_interview.cpp
#include#include using namespace std; #include "sub.h" int main() { string stemp; int itemp; sub sub1[3]; /// that is: sub1[0], sub1[1], sub1[2] ///instantiate via interview ///using a loop to access things in an array with an interview. for(int i=0; i<3; i++) { cout<<"what is the ship's name?"< >itemp; sub1[i].SetLength(itemp); cout<<"how many torpedos are loaded?"< >itemp; sub1[i].SetTorpedos(itemp); ///clear the [enter] from the buffer cin.ignore(); } ///using a loop to display things in an array for(int i=0; i<3; i++) { sub1[i].Display(); } return 0; }
sub_test.cpp
///include the basic libs #include#include using namespace std; #include "sub.h" int main() { sub S1; sub S2("VII",20); /// S1.Display(); S1.SetDesignation("USS Antelope"); S1.SetCaptain("Milard Mallard"); S1.SetType(" IIB "); S1.SetLength(75); S1.SetTorpedos(12); S1.Display(); S1.Fire1(); S1.Display(); S1.Fire2(); S1.Display(); S2.Fire2(); S2.Display(); /// sub Pack[50]; /// for(int i=0; i<50; i++) /// { /// Pack[i].Display(); /// } return 0; }
sub.h
class sub { public: ///required at LEAST 1 constructor sub(){Designation = "none"; Captain = "none"; Type = "none"; Length = 0; Torpedos = 0; } sub(string s, int t){Type = s; Torpedos = t; Length=100;} ///requied at MOST 1 destructor ~sub(){ cout<<"glub ..glub..glub.."<C++ for DND
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started