C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 13th, 2004, 11:50 AM
lostinc++ lostinc++ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 lostinc++ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation 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

Reply With Quote
  #2  
Old December 13th, 2004, 02:30 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
Sorry I can't give it a very detailed look through but as a thought your overloaded operator may need to return bool not int and the returns should be true or false not 1 or 0. Just a thought I really don't know if that'll help.

-KM-

Reply With Quote
  #3  
Old December 13th, 2004, 02:49 PM
lostinc++ lostinc++ is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 lostinc++ User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks, that helped that an issue but not the main issue. which should be simple (just not to me! )

Reply With Quote
  #4  
Old December 13th, 2004, 05:35 PM
kode_monkey kode_monkey is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 367 kode_monkey User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 21 sec
Reputation Power: 6
Ah I see... you have declared temp as an array of length 1 rather than just as a variable. So remove the [1] after snowfall temp.

-KM-

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Sorting error


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT