Please help me fix these two errors. Error 2 fatal error LNK1120: 1unresolved ex
ID: 3618691 • Letter: P
Question
Please help me fix these two errors.Error 2 fatal error LNK1120: 1unresolved externals C:UsersAlexDocumentsVisual Studio2008ProjectsCOP2010DebugCOP2010.exe
Error 1 error LNK2019:unresolved external symbol _main referenced in function___tmainCRTStartup MSVCRTD.lib
#include <iostream>
using namespace std;
class Date
{
private: int day;
int month;
int year;
public:
Date()
{
day=0;
month=0;
year=0;
}
class InvaildDay
{ };
class InvaildMonth
{ };
void setDay(int);
void setMonth(int);
void setYear(int);
int getDay();
int getMonth();
int getYear();
void printFormat1();
void printFormat2();
void printFormat3();
};
void Date::setDay (int d)
{
if (d<1||d>31)
{
throw InvaildDay();
}
else
day=d;
}
void Date::setMonth(int m)
{
if (m<1||m>12)
{
throw InvaildMonth();
}
else
month=m;
}
void Date::setYear (int y)
{
year=y;
}
int Date::getDay()
{
return day;
}
int Date::getMonth()
{
return month;
}
int Date::getYear()
{
return year;
}
void Date::printFormat1()
{
cout<<month<<"/"<<day<<"/0"<<year%10<<endl;
}
Explanation / Answer
i have got an error regarding throw so i changed a little bitthe code, just copy it and run
it on the borland or turbo compiler.
linking problem you got could be the problem of yourcompiler use borland or tuebo or visual studio 6.0 .
#include<iostream.h>
//using namespace std;
class Date
{
private: int day;
int month;
int year;
public:
Date()
{
day=0;
month=0;
year=0;
}
class InvaildDay
{ };
class InvaildMonth
{ };
void setDay(int);
void setMonth(int);
void setYear(int);
int getDay();
int getMonth();
int getYear();
voidprintFormat1();
void printFormat2();
void printFormat3();
};
void Date::setDay (intd)
{
if (d<1||d>31)
{
cout<<" Invalid Day"; //modified
}
else
day=d;
}
void Date::setMonth(intm)
{
if (m<1||m>12)
{
cout<<" Invalid Month"; //modified
}
else
month=m;
}
void Date::setYear (inty)
{
year=y;
}
int Date::getDay()
{
return day;
}
int Date::getMonth()
{
return month;
}
int Date::getYear()
{
return year;
}
voidDate::printFormat1()
{
cout<<month<<"/"<<day<<"/0"<<year%10<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.