I'm trying to alter that values that have been passed into my swimmingPool class. I'm trying to multiply the length, depth, and width values together to get the value for my capacity. However, where I try to use my capacity member function to do this, it returns a junk value. I think my syntax is correct, so I'm why I'm not sure why I'm getting a junk value. Below is my code.
This is my implementation file.
#include <iostream>
#include "SwimmingPoolHeader.h"
using namespace std;
int main()
{
swimmingPool len;
swimmingPool wid;
swimmingPool dep;
swimmingPool cap;
int length;
int width;
int depth;
cout << "Please enter the length of the pool." << endl;
cin >> length;
len.setLength(length);
cout << "Please enter the width of the pool." << endl;
cin >> width;
wid.setWidth(width);
cout << "Please enter the depth of the pool." << endl;
cin >> depth;
dep.setDepth(depth);
cout << "The capacity of the pool is " << cap.capacity() << endl;
system("pause");
return 0;
}
This is my header file.
class swimmingPool {
public:
void setLength(int l)
{
length = l;
}
int getLength()
{
return length;
}
void setWidth(int w)
{
width = w;
}
int getWidth()
{
return width;
}
void setDepth(int d)
{
depth = d;
}
int getDepth()
{
return depth;
}
int capacity()
{
return length * depth * width;
}
private:
int length;
int width;
int depth;
};