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
|
DArray.h:
#pragma once
#include "stdarg.h"
namespace Array {
template<class T>
class DArray {
private:
T* elements;
int dimensions;
int length;
int* lengths;
public:
DArray();
DArray(int dimensions, ...);
T get(...);
void set(T value, ...);
~DArray();
};
}
DArray.cpp:
#include "DArray.h"
using namespace Array;
template<class T>
DArray<T>::DArray() {
}
template<class T>
DArray<T>::DArray(int dimensions, ...) {
//content here not purposeful to the question
}
template<class T>
T DArray<T>::get(...) {
//content here not purposeful to the question
}
template<class T>
void DArray<T>::set(T value, ...) {
//content here not purposeful to the question
}
template<class T>
DArray<T>::~DArray() {
//content here not purposeful to the question
}
StdAfx.h:
#pragma once
#include "DArray.h"
//generates a 2 dimensional matrix of somewhat random integers
Array::DArray<int> generateRandomMatrix(int columns, int rows);
//entry point
int main();
Main.cpp:
#include "stdafx.h"
#include <iostream>
using namespace std;
using namespace Array;
//entry point
int main() {
int x, y;
DArray<int> matrix1, matrix2;
do {
matrix1 = generateRandomMatrix(10, 5);
matrix2 = generateRandomMatrix(2, 6);
for (y = 0; y < 5; y++) {
for (x = 0; x < 10; x++)
printf("%d", matrix1.get(x, y));
}
for (y = 0; y < 6; y++) {
for (x = 0; x < 2; x++)
printf("%d", matrix2.get(x, y));
}
printf("\n\nPress Enter to restart...\n");
getchar();
} while (true);
return 0;
}
//generates a 2 dimensional matrix of somewhat random integers
DArray<int> generateRandomMatrix(int columns, int rows) {
return DArray<int>(columns, rows);
//not actual code, just wrote this to cut things short
}
|