
December 13th, 2004, 11:50 AM
|
|
Registered User
|
|
Join Date: Dec 2004
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Please help with Sorting error!!
Below is my main and the problem function I am trying to sort my array from largest to smallest, however i am getting "error C2440: '=' : cannot convert from 'class snowfall *' to 'class snowfall [1]' There are no conversions to array types, although there are conversions to references or pointers to arrays"
This is a project due tonight and
I have hit every book I have gotten my hands on. PLEASE can someone help!!
Thank you!!!
Code:
void main ()
{
const int arraysize = 10;
snowfall ny [arraysize];
snowfall temp [arraysize];
char ddate [6] = "00/00";
void writeheadings (ofstream&);
void exchange_sort(snowfall[], int);
ifstream data;
data.open("data.txt");
ofstream results;
results.open("results.txt");
if (!data || !results)
cout << "Check data files unable to open required files. \n";
else
writeheadings (results);
for (int i=0; i<9; i++)
{
ny[i].readdata (data);
ny[i].writeresults (results);
ny[i].snowfallconvert ();
}
ny[9].writetotal (results);
for (int j=0; j<9; j++)
exchange_sort(ny, arraysize);
data.close ();
results.close ();
}
And my Problem spot!!!
Code:
void exchange_sort(snowfall *ny[], int size)
{
int i, j;
snowfall temp [1]; // holding variable
for (i=0; i< (size -1); i++) // to represent element to be compared
{
for(j = (i+1); j < size; j++) // to represent the rest of the elements
{
if ( ny[i]->getfeet() < ny[j]->getfeet() )
{
temp = ny[i]; //<-- This is where i am getting my error with the =
ny[i] = ny[j];
ny[j] = temp;
}
}
}
return;
}
Last edited by lostinc++ : December 13th, 2004 at 02:46 PM.
Reason: update
|