Skip to content

Commit a968b42

Browse files
author
Sumit tripathi
committed
templates in C++ use a simple programs
1 parent 323edad commit a968b42

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

Templates.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
#include<iostream>
22
using namespace std;
3+
class vector{
4+
int * arry;
5+
int size;
6+
public:
7+
vector(int m){
8+
size = m;
9+
arry = new int[size];
10+
}
11+
int sumVec(vector & v){
12+
int d = 0;
13+
for (int i = 0; i < size; i++)
14+
{
15+
d += this->arry[i] * arry[i];
16+
return d;
17+
}
18+
19+
}
20+
}
321
int main(){
4-
22+
vector v1(3);
23+
v1.arry[0] = 5;
24+
v1.arry[1 ] = 7;
25+
v1.arry[2] = 57;
526
return 0;
627
}

0 commit comments

Comments
 (0)