First Time Writing a class

it is supposed to make a class that takes birthdate and prints the day number in its year like 1/31/2017 is the 31st day and 2/2/1999 is the 33rd day and so on]
but this error message appears in Xcode /clang:-1: linker command failed with exit code 1 (use -v to see invocation) (note: there is the .h file and .cpp file, starting with the .h)

#include "d_o_f.h"

d_o_f::d_o_f()
{
day = 0;
month = 0;
year = 0;
}
bool checkday(int day)
{
if (day < 32 && day > 0)
return true;
else
return false;
}
bool checkmonth(int month)
{
if (month > 0 && month < 13)
return true;
else
return false
}
bool checkyear(int year)
{
if (year > 0 && year < 10000)
return true;
else
return false
}
bool leapyear (int year)
{
if (year % 4 == 0)
return true
else
return false;
}
int cal_leap(int day, int month, int leap)
{
int count;
switch (month)
{
case (1):
count=+day;
break;
case (2):
count = 31 + day;
break;
case (3):
count = 31 + 29 + day;
break;
case (4):
count = 31 + 29 + 31 + day;
break;
case (5):
count = 31 + 29 + 31 + 30 + day;
break;
case (6):
count = 31 + 29 + 31 + 30 + 31 + day;
break;
case (7):
count = 31 + 29 + 31 + 30 + 31 + 30 + day;
break;
case (8):
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + day;
break;
case (9):
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + day;
break;
case (10):
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
break;
case (11):
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
break;
default:
count = 31 + 29 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
}
return count;
}
int cal_not_leap(int day, int month, int year)
{
int count;
switch (month)
{
case (1):
count=+day;
break;
case (2):
count = 31 + day;
break;
case (3):
count = 31 + 28 + day;
break;
case (4):
count = 31 + 28 + 31 + day;
break;
case (5):
count = 31 + 28 + 31 + 30 + day;
break;
case (6):
count = 31 + 28 + 31 + 30 + 31 + day;
break;
case (7):
count = 31 + 28 + 31 + 30 + 31 + 30 + day;
break;
case (8):
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + day;
break;
case (9):
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + day;
break;
case (10):
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + day;
break;
case (11):
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + day;
break;
default:
count = 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + day;
}
return count;
}
the .cpp
#include <iostream>
using namespace std;

class d_o_f
{
private:
int day;
int year;
int month;
public:
d_o_f();
bool checkday(int);
bool checkmonth(int);
bool checkyear (int);
bool leapyear(int);
int cal_leap(int, int, int);
int cal_not_leap( int, int, int);
};

int main()
{
int d, m, y;
cin >> d;
cin >> m;
cin >> y;
d_o_f e;
if (e.checkday(d) == false)
cin >> d;
if (e.checkmonth(m) == false)
cin >> m;
if (e.checkyear(y) == false)
cin >> y;
if (e.leapyear(y) == false && m > 28)
{
cin >> d;
cin >> m;
cin >> y;
}
if (e.leapyear(y))
cout << e.cal_leap(d, m, y);
else
cout << e.cal_not_leap(d, m, y);
return 0;
}

I know that the code may appear stupid and full of mistakes but keep in mind that this is my first class and I am doing my best
Thank you
Last edited on
linker errors usually mean something was wrong with your compile command, not the code.
how did you try to compile it (exact command)? It can happen if it tries to link after a fail to compile part of it, in that case, show the *compiler* error instead.
Last edited on
Where do you define count.

count=+day;
Did you mean count += day?
I just pressed command + r on my mac
@granado
Thank you
I forgot to intialize it but why isn't xcode showing any errors but, still, the code doesn't run
(I edited my question)
Topic archived. No new replies allowed.