Note that there are some explanatory texts on larger screens.

plurals
  1. POArray Classes - Error: Cannot Convert Parameter from 'double' to 'int'
    primarykey
    data
    text
    <p>I was asking the community about this program earlier, but I've come into one final problem and a quick search on the internet shows me that it's a common one.</p> <p>Below is my code followed by my build output</p> <p><strong>Grader.cpp</strong></p> <pre><code>#include &lt;iostream&gt; #define MAXSIZE 100 #include "Grader.h" Grader::Grader( ){ my_Values [MAXSIZE] = 0; my_ValuesSeenSoFar = 0; } void Grader::addScore( int score ){ if( my_ValuesSeenSoFar &lt; MAXSIZE) my_Values[my_ValuesSeenSoFar++] = score; } void Grader::addScores( int scores[], int size ){ for(int i=0; (i &lt; size) &amp;&amp; (my_ValuesSeenSoFar &lt; MAXSIZE) ; i++) my_Values[my_ValuesSeenSoFar++] = scores[i]; } void Grader::clear(){ for(int i=0; i &lt; MAXSIZE ; i++) my_Values[i] = 0; } int Grader::findBiggest() const{ int max = my_Values[0]; for(int i=1; i &lt; my_ValuesSeenSoFar ; i++) { if( my_Values[i] &gt; max) max = my_Values[i]; } return max; } int Grader::findSmallest( ) const{ int min = my_Values[0]; for(int i=1; i &lt; my_ValuesSeenSoFar ; i++) { if( my_Values[i] &lt; min ) min = my_Values[i]; } return min; } </code></pre> <p><strong>Driver.cpp</strong></p> <pre><code>#include &lt;iostream&gt; #include "Grader.h" using namespace std; int main( ) { Grader g; double d[5]= {99,70,85,93,84}; double e[4]= {100,81,60,91}; g.addScore( 75 ); g.addScore( 82); g.addScores( d, 5 ); cout &lt;&lt; "Best Score = " &lt;&lt; g.findBiggest( ) &lt;&lt; endl; /// should give value 99 cout &lt;&lt; "Worst Score = " &lt;&lt; g.findSmallest( ) &lt;&lt; endl; /// should give value 70 g.clear( ); g.addScore( 50 ); g.addScore( 74 ); g.addScores( e, 4 ); cout &lt;&lt; "Best Score = " &lt;&lt; g.findBiggest( ) &lt;&lt; endl; /// should give value 100 cout &lt;&lt; "Worst Score = " &lt;&lt; g.findSmallest( ) &lt;&lt; endl; /// should give value 50 } </code></pre> <p>And my error output is as follows</p> <blockquote> <p>------ Build started: Project: Grader, Configuration: Debug Win32 ------ Build started 7/29/2013 2:55:05 AM. InitializeBuildStatus: Touching "Debug\Grader.unsuccessfulbuild". ClCompile: Grader.cpp<br> Driver.cpp \psf\home\documents\visual studio 2010\projects\grader\grader\driver.cpp(12): error C2664: 'Grader::addScores' : cannot convert parameter 1 from 'double [5]' to 'int []' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast \psf\home\documents\visual studio 2010\projects\grader\grader\driver.cpp(22): error C2664: 'Grader::addScores' : cannot convert parameter 1 from 'double [4]' to 'int []' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast Generating Code...</p> <p>Build FAILED.</p> <p>Time Elapsed 00:00:01.84 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========</p> </blockquote> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload