I literally just signed up because I'm rather tired of flipping through the stupid text book, so I'm going to admit I'm completely lost :/
I'm using Dev-C++ compiler and it's spitting back the " [Linker error] undefined reference to `getValue(int)' "
I can't figure out why or where my mistake is. It's an assignment for one of my classes. The object of the program is to use user defined functions and have the user input the current year, the current month, their birth year, birth month, and it will tell them how old they are in years and months.
Most of the code was written ahead of time and it's a fill in the blank sort of deal. I'm probably doing it completely wrong.
Code:
#include <iostream>
#include <string>
using namespace std;
// user-defined function prototypes
int getValue(int value = 0);
char getLetter(char letter = 'y');
int main()
{
int thisYear, thisMonth, year, month, ageYear, ageMonth;
char again = 'y';
cout<<"Enter the current year in 4 digit format: ";
cin>>thisYear;
getValue(thisYear);
cout<<"Enter the number of the current month: ";
cin>>thisMonth;
getValue(thisMonth);
while (again == 'y')
{
cout<<"Enter your birth year in 4 digit format: ";
cin>>year;
getValue(year);
cout<<"Enter the number of your birth month: ";
cin>>month;
getValue(month);
ageYear = thisYear - year;
ageMonth = thisMonth - month;
if (thisMonth < month)
{
ageYear--;
ageMonth += 12;
}
cout<<"\nYou are "<<ageYear<<" years and "<<ageMonth
<<"months old.\n";
cout<<"Would you like to enter another birthday? (y/n)\t";
cin>>again;
getLetter(again);
again = tolower(again);
}
system("pause");
return 0;
}
int getValue(string message)
{
int value;
cout<<message;
cin>>value;
return value;
}
char getLetter(string message)
{
char letter;
cout<<message;
cin>>letter;
return letter;
}