-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.1.cpp
61 lines (59 loc) · 988 Bytes
/
1.1.cpp
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
/*Musab Mehadi
*/
#include<iostream>
#include<string>
#include<stdio.h>
using namespace std;
//template <class t>
class complex{
private:
float real;
float imag;
public:
complex(float a,float b)
{
real=a;
imag=b;
}
~complex()
{
//cout<<"destructor implemented"<<endl;
}
/*bool operator==(const complex&c)
{
if( this->real == c.real && this->imag == c.imag)
return true;
else
return false;
}*/
};
template <class t>
int array_search(t elements[],int n,t x)
{
for(int i=0;i<n;i++)
{
if(elements[i]==x)
return i;
}
return -1;
}
int main()
{
int n;
double* d;
cout<<"enter the size of the array"<<endl;
cin>>n;
d=new double[n];
for(int i=0;i<n;i++)
{
cin>>d[i];
}
complex one(5,2);
complex two(1,9);
complex three(7,2);
complex array_of_complexes[3]={one,two,three};
cout<<array_search(d,n,3.5)<<endl;
cout<<array_search(array_of_complexes,3,two)<<endl;
return 0;
}