#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; }
Поделитесь своими знаниями, ответьте на вопрос:
Решите всё должно быть в точности как на картинке
#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; }