#include%26lt;iostream%26gt;
#include%26lt;string%26gt;
#include%26lt;cctype%26gt;
using namespace std;
//getValue
int getValue(int value);
int value=0;
//getLetter
char getLetter(char letter);
char letter='y';
int main()
{
int thisYear=0;
int thisMonth=0;
int year=0;
int month=0;
int ageYear=0;
int ageMonth=0;
char again='y';
cout%26lt;%26lt;"This program asks you to enter today's year in 4 digits,\n";
cout%26lt;%26lt;"and today's month number in 2 digits.\n\n";
cout%26lt;%26lt;"Then it asks you to enter your birth year in 4 digits,\n";
cout%26lt;%26lt;"and your birth month number in 2 digits.\n\n";
cout%26lt;%26lt;"The program will calculate and display your age in years and months.\n";
cout%26lt;%26lt;getValue(thisYear);
cout%26lt;%26lt;getValue(thisMonth);
while (again=='y')
{
//assign to year value returned from getValue.
cout%26lt;%26lt;getValue(year);
//assign to month value returned from getValue.
cout%26lt;%26lt;getValue(month);
ageYear=thisYear-year;
ageMonth=thisMonth-month;
if(thisMonth%26lt;month)
{
ageYear=ageYear--;
ageMonth=ageMonth+12;
}
C++ help.......Back again...this time, i am kinda stuck on user defined functions. i almsot have it working...
where you are calling the gatValue ( year) and the other call you are passing an int down to the fuction. BUT the only getValue you have supplied takes a string as the param.
I think you want
int getValue () {
int i;
cin %26gt;%26gt; i // allow input
return(i); // and give to to the caller
}
then in your main you want
year = getValue( ) ;
cout %26lt;%26lt; year;
Good luck
Reply:Yep yep, you defined int getValue(string) and you are calling int getValue(int), so the linker is looking in all the files it is building for that function, is not finding it, and is coughing. The reason your code compiles is because you *declared* int getValue(int), but you *defined* int getValue(string).
The compiler does not actually match your function calls to the physical code, it just makes sure everything is syntactically and semantically correct. The linker does the heavy lifting of matching function calls with jumps to the right memory addresses.
Reply:int getValue(int) and ur defining method with following method name getValue(string); thats why it is giving err;
edible flowers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment