')' expected error at definition of function.

i am getting an error " ) expected" on turboc++ v3.0
the program is about to insert and manipulate data into an array.
switch structure is used to drive a menu for different operations.

here is the code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include<iostream.h>
#include<conio.h>
class array
{
private:
int ar[20];
public:
void read(int);
void display(int);
void ins(int,int);
int del(int,int);
};
void main()
{
int num=0,exit=1,kth;
array la;
clrscr();

while(exit)
{
int choice;
cout<<"1:enter elements of array/n2:insert an element at kth position/n3:Delete an element from kth position/n4:View all the data stored in array/n5:Exit";
cin>>choice;

switch(choice)
{
case 1:
cout<<"/tenter no. o elements/n";
cin>>num;
la.read(num);
break;

case 2:
cout<<"/nenter the kth position/n";
cin>>kth;
la.ins(kth,num);
break;

case 3:
cout<<"/nenter the kth position/n";
cin>>kth;
cout<<"/nDeleted Item = "<<la.del(kth,num);
break;

case 4:
cout<<"/nelements stored in array/n";
la.display(num);
break;
case 5:    exit=0;

default:
cout<<"/ninvalid option/n";
}
}
getch();
}


void array::display(int a)
{
for(int i=0;i<a;i++)
cout<<ar[i];
}


void array::ins(int loc,a)                                    //here is the error" ) expected"
{
int temp;
if(a==0)
cout<<"arrray is empty use 1st option to enter data";
else if(a==20)
cout<<"Ther is no more space to store more data";
else
cout<<"enter the item";
cin>>temp;
{
for(int i=a;i>loc+1;i--)
ar[i+1]=ar[i];
}
cin>>ar[loc-1];
}


int array::del(int loc,a)
{
if(a==0)
cout<<"there is nothing to delete";
else
{
int temp=ar[loc];
for(int i=loc-1;i<a;i++)
ar[i]=ar[i+1];
}
return temp;
}


void array::read(int a)
{
for(int i=0;i<a;i++)
cin>>ar[i];
}
Last edited on
You need to give a type for each parameter, not just the first one:

1
2
3
void array::ins(int loc,a)  // <- 'a' has no type.  You need to give it one:

void array::ins(int loc, int a)  // <- not it is of type int 


Also for the love of God get a different compiler/build environment. Turbo C++ is a dinosaur. It is so old it actually predates the C++ standard, so you're not really even writing C++... you're writing some other language that is kinda-sorta similar to C++ but has way less features, is less consistent and is more buggy.
oh man that was the problem.
thnks.....
Topic archived. No new replies allowed.