Problem with .h file
Apr 10, 2013 at 3:54pm UTC
Error 1 error LNK1123: failure during conversion to COFF: file invalid or corrupt c:\Users\fred steinman\documents\visual studio 2010\Projects\Date Class 2\Date Class 2\LINK
This is the error I get when I attempt to compile the program.
Here are the files...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#ifndef DATE_H
#define DATE_H
class Date
{
private :
int month;
int day;
int year;
public :
void setMonth(int );
void setDay(int );
void setYear(int );
int getMonth() const ;
int getDay() const ;
int getYear() const ;
};
#endif
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#include <iostream>
#include <string>
#include "Date.h"
using namespace std;
char again;
void Date::setMonth(int m)
{
month = m;
}
void Date:: setDay(int d)
{
day = d;
}
void Date::setYear(int y)
{
year = y;
}
int Date::getMonth() const
{
return month;
}
int Date::getDay() const
{
return day;
}
int Date::getYear() const
{
return year;
}
int main()
{
do
{
Date date;
int dateMonth;
int dateDay;
int dateYear;
string monthName[12] = {"January" , "February" , "March" , "April" , "May" , "June" , "July" ,
"August" , "September" , "October" , "November" , "December" };
cout << "-----Date Class-----" << endl;
cout << "What is the month? " ;
cin >> dateMonth;
if (dateMonth > 12 || dateMonth < 1)
cout << "Month Invalid. Correct month: " ;
cin >> dateMonth;
cout << "What is the day? " ;
cin >> dateDay;
if (dateDay > 31 || dateDay < 1)
cout << "Day Invalid. Correct day: " ;
cin >> dateDay;
cout << "What is the year? " ;
cin >> dateYear;
date.setMonth(dateMonth);
date.setDay(dateDay);
date.setYear(dateYear);
cout << "\nThe date is: " << endl;
cout << date.getMonth() << "/" << date.getDay() << "/" << date.getYear() << endl;
cout << monthName[date.getMonth()-1] << " " << date.getDay() << ", " << date.getYear() << endl;
cout << date.getDay() << " " << monthName[date.getMonth()-1] << " " << date.getYear() << endl;
cout << "\nDo you want to run this program again? Y/N: " ;
cin >> again;
} while (again == 'y' || again == 'Y' );
return 0;
}
Any ideas on how to fix it?
In my compiler, I have the .cpp in the source folder and the .h in the header folder.
Apr 10, 2013 at 4:01pm UTC
It's interesting that the file in the error is called LINK and isn't the name of your header file:
c:\Users\fred steinman\documents\visual studio 2010\Projects\Date Class 2\Date Class 2\LINK
Is this significant?
Reg.
Apr 10, 2013 at 4:09pm UTC
I researched the error and found a solution.
Properties -> Linker(General) -> Incremental Linking -> No
Thanks for the help!
Topic archived. No new replies allowed.