ugh....
I thought declared public and private that I was blind to looking for it. But look at this. I want length to be private so if I just write it a variables within the class that would be correct?
Code:
#include <iostream>
class Plot {
public:
void area(float x, float y)
{
int Area = x * y;
std::cout<< "The area is: "<< Area << std::endl;
}
void parameter(float x, float y)
{
int parameter = 2 * (x + y);
std::cout<<"The parameter is: "<< parameter << std::endl;
}
private:
float length;
float width;
};
int main(int argc, const char * argv[])
{
Plot calculations;
float inLength;
float inWidth;
std::cout<<"Please enter the lenth and width of the object in question?"<<std::endl;
std::cout<<"Lenth:"<<std::endl;
std::cin>>inLength;
std::cout<<"Width: "<<std::endl;
std::cin>>inWidth;
calculations.area(inLength, inWidth);
calculations.parameter(inLength, inWidth);
return 0;
}
Like this:
Code:
class Plot {
public:
void area(float length, float width)
{
int Area = length * width;
std::cout<< "The area is: "<< Area << std::endl;
}
void parameter(float length, float width)
{
int parameter = 2 * (length + width);
std::cout<<"The parameter is: "<< parameter << std::endl;
}
private:
float length;
float width;
};