6 Replies - 1011 Views - Last Post: 07 February 2010 - 01:07 AM Rate Topic: -----

#1 Guest_liop*


Reputation:

local function definition error

Posted 06 February 2010 - 12:38 PM

my code is giving three error two of them say local funtion definition found and the last one say no end of file found.idk why it is giving those error

bool MyList::promptAndInsert(int k,int x)
{
	if(k!=1||k!=2)
	{	
		k=1;
	}
if(x>1||x<ARRAY_SIZE||x<ARRAY_SIZE2)
{	
if(k==1)
	{
	
	cout<<"Enter number to insert in an array"<<endl;
	for(int s=0;s<x;s++)
	{
		cin>>myIntArray[s];

	}
	}

	if(k==2)
	{
	cout<<"Enter number to insert in an array"<<endl;
		for(int l=0;l<x;l++)
		{
			cin>>myArrayCopy[l];

		}


	}

	return true:
}
return false;


}


void MyList::compareArrays()
{
for(int v=0; v<ARRAY_SIZE2;v++)
	{
	
	if(myIntArray[v]==myArrayCopy[v])
	
		cout<<"found "<<myIntArray[v]<<"    "<<"at index"<<v<<endl;
	
	}
}


Is This A Good Question/Topic? 0

Replies To: local function definition error

#2 liop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 22-February 09

Re: local function definition error

Posted 06 February 2010 - 12:49 PM

my code is giving three error two of them say local funtion definition found and the last one say no end of file found.idk why it is giving those error
bool MyList::promptAndInsert(int k,int x)
{
	if(k!=1||k!=2)
	{	
		k=1;
	}
if(x>1||x<ARRAY_SIZE||x<ARRAY_SIZE2)
{	
if(k==1)
	{
	
	cout<<"Enter number to insert in an array"<<endl;
	for(int s=0;s<x;s++)
	{
		cin>>myIntArray[s];

	}
	}

	if(k==2)
	{
	cout<<"Enter number to insert in an array"<<endl;
		for(int l=0;l<x;l++)
		{
			cin>>myArrayCopy[l];

		}


	}

	return true:
}
return false;


}


void MyList::compareArrays()
{
for(int v=0; v<ARRAY_SIZE2;v++)
	{
	
	if(myIntArray[v]==myArrayCopy[v])
	
		cout<<"found "<<myIntArray[v]<<"    "<<"at index"<<v<<endl;
	
	}
}



Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5303
  • View blog
  • Posts: 27,191
  • Joined: 10-May 07

Re: local function definition error

Posted 06 February 2010 - 12:50 PM

I don't see a function for main. Every C/C++ program requires a function for main.

** Renamed title to be more descriptive **
Was This Post Helpful? 0
  • +
  • -

#4 oQMr FoxQo  Icon User is offline

  • D.I.C Head

Reputation: 16
  • View blog
  • Posts: 123
  • Joined: 16-August 09

Re: local function definition error

Posted 06 February 2010 - 01:10 PM

1. Next time use [ code ] [ /code ] to implement your code:
2. return true: should be return true;
3. most of the time the local function are illegal error happen when you don't close body or when declare a function inside another function wich will produc this error
oQMr FoxQo
Was This Post Helpful? 1
  • +
  • -

#5 jjl  Icon User is offline

  • Engineer
  • member icon

Reputation: 1074
  • View blog
  • Posts: 4,533
  • Joined: 09-June 09

Re: local function definition error

Posted 06 February 2010 - 01:13 PM

post code
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6062
  • View blog
  • Posts: 23,513
  • Joined: 23-August 08

Re: local function definition error

Posted 06 February 2010 - 01:14 PM

Merged duplicate topics
Was This Post Helpful? 0
  • +
  • -

#7 PlasticineGuy  Icon User is offline

  • mov dword[esp+eax],0
  • member icon

Reputation: 281
  • View blog
  • Posts: 1,436
  • Joined: 03-January 10

Re: local function definition error

Posted 07 February 2010 - 01:07 AM

Here's your code indented properly:
bool MyList::promptAndInsert(int k,int x)
{
        if(k!=1||k!=2)
        {       
                k=1;
        }
	if(x>1||x<ARRAY_SIZE||x<ARRAY_SIZE2)
	{       
	if(k==1)
        {
        	cout<<"Enter number to insert in an array"<<endl;
        	for(int s=0;s<x;s++)
        	{
                	cin>>myIntArray[s];

	        }
        }

        if(k==2)
        {
	        cout<<"Enter number to insert in an array"<<endl;
                for(int l=0;l<x;l++)
                {
                        cin>>myArrayCopy[l];

                }
        }
        return true:
}
return false;
}


void MyList::compareArrays()
{
	for(int v=0; v<ARRAY_SIZE2;v++)
        {
        	if(myIntArray[v]==myArrayCopy[v])
               		cout<<"found "<<myIntArray[v]<<"    "<<"at index"<<v<<endl;
        
        }
}

Notice how you have return false; outside the function definition?
Also, you need the int main() function. Do yourself a favour and read an introductory C++ tutorial.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1