Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<blockquote> <p>error C2601: 'X' : local function definitions are illegal</p> </blockquote> <p>It sounds like you're defining a function inside another function; C++ doesn't allow you to do that. Move the definition of <code>X</code> outside the function it's currently in.</p> <p>Another possibility is that there's another function immediately before <code>X</code>, and you missed out the <code>}</code> at the end of that function.</p> <blockquote> <p>The problem is that matrix_entry, temp and M are undeclared identifier But in my main I have this:</p> </blockquote> <p>Firstly, types need to be declared before they're used. It sounds like this function appears either before the definition of <code>matrix_entry</code>, or in a different source file.</p> <p>Either move the definition of <code>matrix_entry</code> to a point before anything needs to use it, or put it in a header and include that from each source file that needs it. That will fix the first two "undeclared identifier" errors for <code>matrix_entry</code> and <code>temp</code>.</p> <p>If <code>M</code> is in <code>main</code>, then it's not available in other functions. You could pass it to the function(s) that need it:</p> <pre><code>void Mode(matrix_entry * M){ matrix_entry temp; temp=M[i]; M[i]=M[small_i]; M[small_i]=temp; } int main() { matrix_entry *M = new matrix_entry [10]; //... Mode(M); //... // Don't forget to delete anything you new // (Better still don't new it in the first place, // or use smart pointers if you must) delete [] M; } </code></pre>
 

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