The thing is I am keeping the main code in one file and calling functions from the other file. But it gives me LNK 2005 error every time I try to compile it. Can anyone please help me what I am doing wrong here? I am a newbie in C++ so please help me.
main file
#include "stdafx.h"
#include "forwards.cpp" // All the functions are forwarded in this file.
int main()
{
using namespace std;
cout << "Approximate Age Calculator till 31-12-2015" << endl;
cout << endl;
cout << "Type your birth year: ";
cin >> yy;
cout << "Type your birth month: ";
cin >> mm;
cout << "Type your day of birth: ";
cin >> dd;
cout << "Your approximate age is ";
cout << yearCalculator() << " years, ";
cout << monthCalculator() << " months and ";
cout << daysCalculator() << " days" << endl;
cout << endl;
}
forwards.cpp
#include "stdafx.h"
int dd;
int mm;
int yy;
int a;
int daysCalculator()
{
int a = 31 - dd;
return a;
}
int monthCalculator()
{
int a = 12 - mm;
return a;
}
int yearCalculator()
{
int a = 2015 - yy;
return a;
}