Article View: att.lang.c++
Article #31compiler error
From: Comcast
Date: Fri, 23 Nov 2007 23:52
Date: Fri, 23 Nov 2007 23:52
125 lines
4610 bytes
4610 bytes
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;
}
}
Technical Details
Message-ID:
<5r-dnf-yNbbR-tranZ2dnUVZ_uyinZ2d@comcast.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10d4ba,994dc82cc5c34cc6,start X-Google-Attributes: gid10d4ba,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 23 Nov 2007 17:50:36 -0600 From: "Comcast" <aikiart7@gmail.com> Newsgroups: att.lang.c++ Subject: compiler error Date: Fri, 23 Nov 2007 18:52:21 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 Message-ID: <5r-dnf-yNbbR-tranZ2dnUVZ_uyinZ2d@comcast.com> Lines: 127 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 24.98.253.225 X-Trace: sv3-GINDmRM0VIIEV+gL26LXxIrpcZDeOLSqs8Qefw11fHy2r4LafkrL7c+gy8Mmrdkc6BGVA8I70+huTgd!8N8zDFapC/1Hr9rnMA/Qhx5/1lqDjcFz/KSOJvds1VJSosC6Pao7z0O/2IVC5tTLD9KO1OOIzlPR!rXUATTQkGFYLpa59Qgc9E669dYB1pg== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.35