cal

ok sorry for this long code ...

it show me bunch of errors


1>calendarType.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
1>calendarType.obj : error LNK2019: unresolved external symbol "public:
1>calendarType.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * dayType::weekDays"


***********int main *****************


#include "dateType.h"
#include "extdateType.h"
#include "dayType.h"
#include "calendarType.h"
#include <iostream>
using namespace std;

int main()
{
char q;
int month;
int year;
int SENTINEL = -9999;
int userSent = 0;
while (userSent != SENTINEL)
{
cout << "Please enter a month: ";
cin >> month;
cout << "\n";

cout << "Please enter a year: ";
cin >> year;
cout << "\n";

calendarType cal(month, year); //for 2014, first day for each month,
//6 is sunday
//9 is monday
//4 tuesday
//10 wednesday
//5 is thursday
//8 is friday
//11 is saturday

cal.printCalendar();
cout << "If you would like to continue, type 0 and hit enter. " << "\n" << "If you would like to quit, type -9999 and hit enter. ";
cin >> userSent;
cout << "\n";

}
return 0;
}


********************calendarType.h***********

#ifndef calendarType_h
#define calendarType_h

#include "dateType.h"
#include "extdateType.h"
#include "dayType.h"
#include <iostream>

class calendarType
{
public:
void setMonth(int m);
void setYear(int y);
int getMonth();
int getYear();
void printCalendar();
calendarType();
calendarType(int m, int y);
private:
// Note that member functions can also be private which means only functions
// within this class can call them.
dayType firstDayOfMonth();
void printTitle();
void printDates();

// Composition rather than inheritance, although firstDate is a derived class
// from the base class dateType.
extDateType firstDate;
dayType firstDay;
};
#endif

*****************dateType.h******************

#ifndef dateType_H
#define dateType_H
class dateType
{
public:
void setDate(int, int, int);
void setMonth(int);
void setDay(int);
void setYear(int);
int getMonth() const;
int getDay() const;
int getYear() const;
void print() const;
int getDaysInMonth();
int numberOfDaysPassed();
int numberOfDaysLeft();
void incrementDate(int nDays);
bool isLeapYear();
dateType(int = 1, int = 1, int = 1900);
private:
int dMonth;
int dDay;
int dYear;
};
#endif

*************************dayType.h***********************

#ifndef dayType_H
#define dayType_H
#include <string>
using namespace std;
class dayType
{
public:
static string weekDays[7];
void print() const;
string nextDay() const;
string prevDay() const;
void addDay(int nDays);
void setDay(string d);
string getDay() const;
dayType();
dayType(string d);

private:
string weekDay;
};
#endif

********************extdateType.h***********

#ifndef extDateType_H
#define extDateType_H
#include <string>
#include "dateType.h"
using namespace std;
class extDateType : public dateType
{
public:
static string eMonths[12];
void printLongDate();
void setDate(int, int, int);
void setMonth(int m);
void printLongMonthYear();
extDateType();
extDateType(int, int, int);
private:
string eMonth;
};
#endif

****************dayType.ccp***************

#include <iostream>
#include "dateType.h"
using namespace std;
void dateType::setDate(int month, int day, int year)
{
if (year >= 1)
dYear = year;
else
dYear = 1900;

if (1 <= month && month <= 12)
dMonth = month;
else
dMonth = 1;

switch (dMonth)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
if (1 <= day && day <= 31)
dDay = day;
else
dDay = 1;
break;
case 4:
case 6:
case 9:
case 11:
if (1 <= day && day <= 30)
dDay = day;
else
dDay = 1;
break;
case 2:
if (isLeapYear())
{
if (1 <= day && day <= 29)
dDay = day;
else
dDay = 1;
}
else
{
if (1 <= day && day <= 28)
dDay = day;
else
dDay = 1;
}
}
}
void dateType::setMonth(int m)
{
dMonth = m;
}
void dateType::setDay(int d)
{
dDay = d;
}
void dateType::setYear(int y)
{
dYear = y;
}
void dateType::print() const
{
cout << dMonth << "-" << dDay << "-" << dYear;
}
int dateType::getMonth() const
{
return dMonth;
}
int dateType::getDay() const
{
return dDay;
}
int dateType::getYear() const
{
return dYear;
}
int dateType::getDaysInMonth()
{
int noOfDays;
switch (dMonth)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
noOfDays = 31;
break;
case 4:
case 6:
case 9:
case 11:
noOfDays = 30;
break;
case 2:
if (isLeapYear())
noOfDays = 29;
else
noOfDays = 28;
}
return noOfDays;
}
bool dateType::isLeapYear()
{
if (((dYear % 4 == 0) && (dYear % 100 != 0)) || dYear % 400 == 0)
return true;
else
return false;
}
dateType::dateType(int month, int day, int year)
{
setDate(month, day, year);
}
int dateType::numberOfDaysPassed()
{
int monthArr[13] = {0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
int sumDays = 0;
int i;
for (i = 1; i < dMonth; i++)
sumDays = sumDays + monthArr[i];
if (isLeapYear() && dMonth > 2)
sumDays = sumDays + dDay + 1;
else
sumDays = sumDays + dDay;
return sumDays;
}
int dateType::numberOfDaysLeft()
{
if (isLeapYear())
return 366 - numberOfDaysPassed();
else
return 365 - numberOfDaysPassed();
}
void dateType::incrementDate(int nDays)
{
int monthArr[13] = {0, 31, 28, 31, 30, 31, 30,
31, 31, 30, 31, 30, 31};
int daysLeftInMonth;
daysLeftInMonth = monthArr[dMonth] - dDay;

if (daysLeftInMonth >= nDays)
dDay = dDay + nDays;
else
{
dDay = 1;
dMonth++;
nDays = nDays - (daysLeftInMonth + 1);

while (nDays > 0)
if (nDays >= monthArr[dMonth])
{
nDays = nDays - monthArr[dMonth];

if ((dMonth == 2) && isLeapYear())
nDays--;

dMonth++;
if (dMonth > 12)
{
dMonth = 1;
dYear++;
}
}
else
{
dDay = dDay+nDays;
nDays = 0;
}
}
}
Last edited on
welcome! This is too much to read without any formatting. Edit your post and put in code tags, the <> on the side bar editor or the word code in [] brackes and [/] to end the code block.

also, describe what it should do and what it does wrong. "this giant block of random code does not work" is not helpful. "this crashes when I type in blah" or "this says 23 and should say 42" would tell us a lot more
PLEASE learn to use code tags, they make reading and commenting on source code MUCH easier.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

HINT: you can edit your post and add code tags.
why this program is not working ?

Does the code compile? If not, what errors are you getting?

If it does compile what is your EXPECTED output, and what output are you actually getting?

We are not in the room with you, looking at your computer screen. You have to tell us in more detail what is going wrong.
@jonin and @Furry Guy: The OP did state his issue:

1>calendarType.obj : error LNK2019: unresolved external symbol "public: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >
1>calendarType.obj : error LNK2019: unresolved external symbol "public:
1>calendarType.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * dayType::weekDays"


@OP: The linker is telling you that it can't find certain symbols when it tries to link your program. The linker errors are coming from calendarType.obj, however you did not provide the source for calendarType.cpp so we can't reproduce your problem.

PLEASE ALWAYS USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.
@AbstractionAnon,

The OP edited their post after our replies, the errors weren't there when we replied. What I quoted was edited out.

If only they had edited the post and added code tags.
Topic archived. No new replies allowed.