-2

im having trouble with an assignment, i need to make a swimming pool class and have it ask user for the pools info so that it may then give you the time it will take to fill the pool based on how much water is in it. first issue is with the pool1.setsize(), pool1.setfillrate(), setarea, setlevel im getting errors LNK2019 for them there are also a few syntax errors that i cant figure out how to get rid of, one is in the .gettime() says too few arguments but im not trying to pass a argument im trying to get the int time sent back

#include "stdafx.h"
#include <iostream>
using namespace std;

class swimmingpool
{
public:
    void setsize(int, int, int);
    void setarea(int);
    void setfillrate(int);
    void setdrainrate(int);
    int gettime(int&);
    void setlevel(int);
    level = level * length * width;
    level = area - level;
    Time = level / fillrate;


private:
    int length;
    int width;
    int depth;
    int area;
    int fillrate;
    int drainrate;
    int Time;
    int level;


};
int _tmain()
{
    swimmingpool pool1;
    int len;
    int wid;
    int dep;
    int are;
    int fill;
    int drn;
    int lvl;
    int time;

    cout << "enter length, width, depth" << endl;
    cin >> len;
    cin >> wid;
    cin >> dep;
    cout << endl;

    pool1.setsize(len, wid, dep);

    are = len * wid * dep;
    pool1.setarea(are);

    cout << "enter the fill rate (int only for a sqft per hr)" << endl;
    cin >> fill;
    cout << endl;

    pool1.setfillrate(fill);

    cout << "enter water level" << endl;
    cin >> lvl;
    cout << endl;

    pool1.setlevel(lvl);

    time = pool1.gettime();

    //lvl = lvl * len * wid;
    //lvl = are - lvl;
    //time = lvl / fill;

    cout << " it will take " << time << " hours" " to fill " << lvl << " sqft in the pool" << endl;

    system("pause");
    return 0;
stev0104
  • 45
  • 1
  • 3
  • 11

1 Answers1

1

The linker error tells you that there is no implementation for member functions declared in your class. Try adding implementation code after the class declaration (after the }; ) in the following manner:

void swimmingpool::setsize(int len, int wid, int dep)
{
    length = len;
    width = wid;
    depth = dep;
}

You'll also need to do this for all the member functions (setarea, setfillrate, setdrainrate, gettime, setlevel)

BTW this chunk of code won't compile:

level = level * length * width;
level = area - level;
Time = level / fillrate;

It feels like the code above should probably be inside the setlevel function, at least partially. Good luck.

Anton
  • 1,183
  • 10
  • 19