Question: 3 C++ Errors, please help Hello, I am getting 3 errors in my code that I have not figured out how to sort out. The
3 C++ Errors, please help
Hello, I am getting 3 errors in my code that I have not figured out how to sort out.
The first: error c1083: Cannot open include file: 'Rectangle.h": No such file or directory
The second: Intellisense: cannot open source file "Rectangle.h"
The third: Intellisense: cannot open source file "Rectangle.h"
My code below:
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
#ifndef RECTANGLE_H
#define RECTANGLE_H
class Rectangle {
public:
Rectangle();
void setLength( float );
void setWidth( float );
float getLength();
float getWidth();
float getArea();
float getPerimeter();
private:
float length;
float width;
};
# endif
#include
using std::cout;
#include "Rectangle.h"
Rectangle::Rectangle()
{
setLength( 1.0 );
setWidth( 1.0 );
}
void Rectangle::setLength( float myLength )
{
if( ( myLength < 20 ) && ( myLength > 0 ) )
length = myLength;
else
{
cout << " \tInvalid Length. Default length will be assigned. ";
length = 1.0;
}
}
void Rectangle::setWidth( float myWidth )
{
if ( ( myWidth < 20 ) && ( myWidth > 0 ) )
width = myWidth;
else
{
cout << " \tInvalid wifth. Default width will be assigned.";
width = 1;
}
}
float Rectangle::getLength()
{
return length;
}
float Rectangle::getWidth()
{
return width;
}
float Rectangle::getArea()
{
return ( length * width );
}
float Rectangle::getPerimeter()
{
return ( 2 * ( length + width ) );
}
#include
using std::cout;
using std::cin;
#include "Rectangle.h"
int main()
{
float t;
cout << " \tA program that works with Rectangle class.";
Rectangle myRectangle;
cout << " \tInitial values of rectangle were: "
<< " \tLength = " << myRectangle.getLength()
<< " \tWidth = " << myRectangle.getWidth();
cout << "/n/n/tModify the rectangle dimensions. ";
cout << " \tEnter length: ";
cin >> t;
myRectangle.setLength( t );
cout << " \tEnter width: ";
cin>>t;
myRectangle.setWidth( t );
cout << " \tAfter modifying values, dimensions are: "
<< " \tLength = " << myRectangle.getLength()
<< " \tWidth = " << myRectangle.getWidth();
cout <<" \tThe area of rectangle is: "
<< myRectangle.getArea();
cout << " \tThe perimeter of rectangle is: "
<< myRectangle.getPerimeter();
cout << " \t";
system( "pause" );
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
