Commit 9cfc078a by Patryk Czarnik

Implementacja oparta o tablicę stałego rozmiaru

parent 61b446e2
......@@ -2,6 +2,7 @@
#include "wektor.h"
Wektor::Wektor()
: liczba_elementow{0}
{}
Wektor::~Wektor() {
......@@ -9,13 +10,15 @@ Wektor::~Wektor() {
}
void Wektor::push_back(int e) {
t[liczba_elementow] = e;
liczba_elementow++;
}
void Wektor::set(int idx, int e) {
// FIXME kontrola zakresu
t[idx] = e;
}
int Wektor::get(int idx) {
return 13;
return t[idx];
}
......@@ -5,6 +5,10 @@
/** Tablica zmiennej długości zawierająca wartości int. */
class Wektor {
int t[10];
// logiczny rozmiar wektora = ile pozycji w tablicy jest zajętych = indeks pierwszej wolnej pozycji
int liczba_elementow;
public:
Wektor();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment