Question

For the following C++ code, identify the 10 errors and rewrite the code using the space...

For the following C++ code, identify the 10 errors and rewrite the code using the space provided below.

Do not write a new program just add, remove or change the characters/words that make the code incorrect.

#include "iostream>
using namespace std:


class Line
{
public:
Line( double L ) [ setLength(L); }
void setLength( double L ) { length = L }
double getLength( void ) { return length; }
private=
double length;
};


int main()
{
double len;
cout >> "How long is this line? "
cin >> len;

Line = line(len);
Line *LPtr = line;
cout << "Length of line : " << LPtr.getLength() << endl;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;

class Line
{
public:
Line( double L ) { setLength(L); }
void setLength( double L ) { length = L; }
double getLength( void ) { return length; }
private:
double length;
};


int main()
{
double len;
cout << "How long is this line? ";
cin >> len;

Line = line(len);
Line *LPtr = line;
cout << "Length of line : " << LPtr.getLength() << endl;
return 0;
}

I change this lines.

#include<iostream>
using namespace std;
Line( double L ) { setLength(L); }
void setLength( double L ) { length = L; }

private:

cout << "How long is this line? ";

return 0;

but their is some error remains.To correct those error i need to know about exactly what is the working of this lines are ?

what is you intention of writing this lines of code.

Line = line(len);
Line *LPtr = line;

Add a comment
Know the answer?
Add Answer to:
For the following C++ code, identify the 10 errors and rewrite the code using the space...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT