Answer to Question #184074 in C++ for Bilal

Question #184074

Comment this code line by line in simple english

include <iostream>
 
 
using namespace std;
 
 
class Line {
 
   public:
 
      void setLength( double len );
 
      double getLength( void );
 
      Line();
 
   private:
 
      double length;
 
};
 
 
 
Line::Line(void) {
 
   cout << "Object is being created" << endl;
 
}
 
void Line::setLength( double len ) {
 
   length = len;
 
}
 
double Line::getLength( void ) {
 
   return length;
 
}
 
 
 
int main() {
 
   Line line;
 
 
 
   line.setLength(6.0);
 
   cout << "Length of line : " << line.getLength() <<endl;
 
 
   return 0;
 
}
 
1
Expert's answer
2021-04-26T14:51:16-0400
include <iostream>              //impplement header file
 
 
using namespace std;    //provide sope to identifiers
 
 
class Line {        //maek class namae line
 
   public:  //give access public 
 
      void setLength( double len );
 
      double getLength( void );
 
      Line();      //make constructor
 
   private:
 
      double length;    //make variable name length of variable double
 
};
 
 
 
Line::Line(void) {   defination of functoin 
 
   cout << "Object is being created" << endl;     //printing statement
 
}
 
void Line::setLength( double len ) {    //defination of function
 
   length = len;
 
}
 
double Line::getLength( void ) {  //  defination of function that return type double
 
   return length;    //returning statement
 
}
 
 
 
int main() {   //main function
 
   Line line;   // create variable line of type line
 
 
 
   line.setLength(6.0);  //call function
 
   cout << "Length of line : " << line.getLength() <<endl;  //printing statement and calling function
 
 
   return 0;    //returning statement
 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS