From: Comcast on
Can anyone help:
When I compile this code, I'm getting

[{Linker error] undefined reference to 'getData(WeatherStats*,int)'

I'm not sure what is causing the error.

Thanks
Art



// This program creates a weather stat structure
// and calculates avg. monthly rainfall, total
// annual rainfall, annual highest and lowest temps
// and the months they occurred and the avg montly temp/
// using the computed avg of all months


#include <iostream>
#include <iomanip>

using namespace std;

//function prototypes

void holdHigh(int [] ,int);

enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};

//function prototype for displayMonth
void displayMonth(int);

struct WeatherStats
{
float rainFall; //total rainfall by month
float highTemp; //high temp for month
float lowTemp; //low temp for month
float avgTemp; //avg temp for month
};
//function prototype for data getData

void getData(WeatherStats[], int);

void getMonth(int);

int main()
{
const int NUM_MONTHS = 12; //number of months
WeatherStats currentYear[NUM_MONTHS]; // array of WeatherStats
//Month currentMonth; //define enum for type Month

getData(currentYear, NUM_MONTHS); //function call to getData


system("PAUSE");
}




void getData(WeatherStats currentMonth, int theMonth)
{
WeatherStats tempWeatherStats[theMonth]; //temp for holding
structure variables
for (int x=0;x < theMonth; x++)
{
cout << "Please enter the rainfall for ";
displayMonth(theMonth);
cout <<": ";
cin >> tempWeatherStats[x].rainFall;
cout << "Please enter the high temperature for ";
displayMonth(theMonth);
cout <<": ";
cin >> tempWeatherStats[x].highTemp;
cout << "Please enter the low temperature for ";
displayMonth(theMonth);
cout <<": ";
cin >> tempWeatherStats[x].lowTemp;
tempWeatherStats[x].avgTemp = (tempWeatherStats[x].highTemp +
tempWeatherStats[x].lowTemp)/2;
}

}

//function to display month name

void displayMonth(int month)
{
switch(month)
{
case JAN :cout << "January";
break;
case FEB :cout << "February";
break;
case MAR :cout << "March";
break;
case APR :cout << "April";
break;
case MAY :cout << "May";
break;
case JUN :cout << "June";
break;
case JUL :cout << "July";
break;
case AUG :cout << "August";
break;
case SEP :cout << "September";
break;
case OCT :cout << "October";
break;
case NOV :cout << "November";
break;
case DEC :cout << "December";
break;
}
}










From: Richard Heathfield on
Comcast said:

> Can anyone help:
> When I compile this code, I'm getting
>
> [{Linker error] undefined reference to 'getData(WeatherStats*,int)'
>
> I'm not sure what is causing the error.

I am. :-)

> //function prototype for data getData
>
> void getData(WeatherStats[], int);

See this?

> void getData(WeatherStats currentMonth, int theMonth)

See this?

Spot the difference?

[Hint]

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
From: Comcast on
Thank Richard,

got the hint


Thanks

Art
"Richard Heathfield" <rjh(a)see.sig.invalid> wrote in message
news:Nvudna_tEfWq9NranZ2dnUVZ8uadnZ2d(a)bt.com...
> Comcast said:
>
>> Can anyone help:
>> When I compile this code, I'm getting
>>
>> [{Linker error] undefined reference to 'getData(WeatherStats*,int)'
>>
>> I'm not sure what is causing the error.
>
> I am. :-)
>
>> //function prototype for data getData
>>
>> void getData(WeatherStats[], int);
>
> See this?
>
>> void getData(WeatherStats currentMonth, int theMonth)
>
> See this?
>
> Spot the difference?
>
> [Hint]
>
> --
> Richard Heathfield <http://www.cpax.org.uk>
> Email: -http://www. +rjh@
> Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
> "Usenet is a strange place" - dmr 29 July 1999