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;
}
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
}
Comments
Leave a comment