Compiler error

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 2
Reputation: thiodre26 is an unknown quantity at this point 
Solved Threads: 0
thiodre26 thiodre26 is offline Offline
Newbie Poster

Compiler error

 
0
  #1
Nov 17th, 2004
Greetings:

I am taking my first C++ class and am a little stuck. I keep receiving three compiler errors, but I can't seem to figure them out. Can someone please point me in the right direction.

The assignment is:

Write a C++ program having a recursive function recursiveMinimum that takes an integer array and the array size as arguments and returns the smallest element of the array. The function should stop processing and return when it receives an array of 1 element.

I am attaching my .cpp file.

Thanks to anyone that can assist me.

By the way, God bless all you gurus. If this is a beginner's class, I hate to see the advanced classes.
Attached Files
File Type: cpp main.cpp (415 Bytes, 28 views)
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,783
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 744
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Compiler error

 
0
  #2
Nov 17th, 2004
>I am attaching my .cpp file.
Don't do this. Post the code. If the code is too long, post relevant pieces. Your attachment is very small, so the code is short enough to post.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 11
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: Compiler error

 
0
  #3
Nov 17th, 2004
You were doing fine up until this routine:
  1. int recursiveMinimum(int[] array, int size)
  2. {
  3. if size<=1 return -1;
  4. if array[index]<smallest
  5. smallest=array[index];
  6. index++;
  7. recursiveMinimum(array, size);
  8. return smallest;
  9. }

1) should be int array[] not int[] array
2) if statements always have their argument in parens, like "if (size <=1) return -1;"

Next time, please post the exact error message too so we don't have to play compiler for you. :-)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC