CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2009
    Posts
    2

    [RESOLVED] Error Message during compiling

    Hi!
    I keep getting an error
    "expected constructor, destructor, or type conversion before '=' token "
    but i have no idea how to fix it or why its even coming up. please help!! Thanks!!

    Source File:
    #include <iostream>
    #include <iomanip>
    using namespace std;
    int smallestIndex (int sizeArray, int arrayName[]);
    int smallestIndex(int sizeArray, int arrayName[])
    {
    int minIndex=0;
    int index;
    for (index=1; index<sizeArray; index++)
    if (arrayName[index]<arrayName[minIndex])
    { minIndex=index;}

    return minIndex;
    }

    int main()
    {int arraySize;
    int i;
    bool done=false;

    cout<<"Function smallestIndex"<<endl;
    while (!done)
    {
    cout<<"Enter the number of integers: ";
    cin>>arraySize;
    if(!cin)
    {cout<<"Incorrect input. Try again. "<<endl;
    cin.clear();
    cin.ignore(200,'\n');
    }
    else done=true;
    }
    int yourInput[arraySize];
    done=false;
    cout<<"Enter the integers: ";
    while (!done)
    {
    for (i=0; i<arraySize; i++)
    {cin>>yourInput[i];}
    if(!cin)
    {cout<<"Incorrect input. Try again and enter the integers: ";
    cin.clear();
    cin.ignore(200,'\n');
    }
    else done=true;
    }
    }
    int value=0;
    value = smallestIndex(arraySize, yourInput); //<--ERROR MESSAGES START HERE
    cout<<"The smallest number in the set you entered is in position ";
    cout<<value<<" and is the number "<<yourInput[valueReturned];
    cout<<". "<<endl;
    system ("pause"); /* gives the "press any key to
    continue" command that is missing from compiler
    on home pc*/
    return 0;
    }

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: Error Message during compiling

    You have an extra closing brace. That would be obvious if your code were properly indented.

  3. #3
    Join Date
    Jun 2009
    Posts
    2

    Re: Error Message during compiling

    yeah i would be the idiot to do that. Thanks!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured