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
#include "stdafx.h"
#include "stdio.h"
#include <time.h>
#include <stdlib.h>
class vector
{
private:
int* m;
int size;
public :
vector(int n = 0);
vector(const vector &vector2);
~vector();
};
vector::vector( int n )
if (n < 0) n = 0;
size = n;
m = new int[n];
if(!m)
printf("Error");
else
m = NULL;
}
vector::vector(const vector &vector2)
size = vector2.size;
m = new int [size];
for(int i = 0; i<size;i++)
m[i] = vector2.m[i];
printf("kopia stvorena !");
vector::~vector()
delete[] m;
vector(int *m, int size)
srand(time(NULL))
printf("error")
for(int i = 0; i < size; i++)
m[i] = rand()% 99;
int main()
vector v1(45),
system("pause");
return 0;
Объяснение:
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
#include "stdafx.h"
#include "stdio.h"
#include <time.h>
#include <stdlib.h>
class vector
{
private:
int* m;
int size;
public :
vector(int n = 0);
vector(const vector &vector2);
~vector();
};
vector::vector( int n )
{
if (n < 0) n = 0;
size = n;
m = new int[n];
if(!m)
printf("Error");
else
m = NULL;
}
vector::vector(const vector &vector2)
{
size = vector2.size;
m = new int [size];
for(int i = 0; i<size;i++)
m[i] = vector2.m[i];
printf("kopia stvorena !");
}
vector::~vector()
{
delete[] m;
}
vector(int *m, int size)
{
srand(time(NULL))
if(!m)
printf("error")
else
for(int i = 0; i < size; i++)
m[i] = rand()% 99;
}
int main()
{
vector v1(45),
system("pause");
return 0;
}
Объяснение:
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
#include "stdafx.h"
#include "stdio.h"
#include <time.h>
#include <stdlib.h>
class vector
{
private:
int* m;
int size;
public :
vector(int n = 0);
vector(const vector &vector2);
~vector();
};
vector::vector( int n )
{
if (n < 0) n = 0;
size = n;
m = new int[n];
if(!m)
printf("Error");
else
m = NULL;
}
vector::vector(const vector &vector2)
{
size = vector2.size;
m = new int [size];
for(int i = 0; i<size;i++)
m[i] = vector2.m[i];
printf("kopia stvorena !");
}
vector::~vector()
{
delete[] m;
}
vector(int *m, int size)
{
srand(time(NULL))
if(!m)
printf("error")
else
for(int i = 0; i < size; i++)
m[i] = rand()% 99;
}
int main()
{
vector v1(45),
system("pause");
return 0;
}