Commit 9cfc078a by Patryk Czarnik

Implementacja oparta o tablicę stałego rozmiaru

parent 61b446e2
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "wektor.h" #include "wektor.h"
Wektor::Wektor() Wektor::Wektor()
: liczba_elementow{0}
{} {}
Wektor::~Wektor() { Wektor::~Wektor() {
...@@ -9,13 +10,15 @@ Wektor::~Wektor() { ...@@ -9,13 +10,15 @@ Wektor::~Wektor() {
} }
void Wektor::push_back(int e) { void Wektor::push_back(int e) {
t[liczba_elementow] = e;
liczba_elementow++;
} }
void Wektor::set(int idx, int e) { void Wektor::set(int idx, int e) {
// FIXME kontrola zakresu
t[idx] = e;
} }
int Wektor::get(int idx) { int Wektor::get(int idx) {
return 13; return t[idx];
} }
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
/** Tablica zmiennej długości zawierająca wartości int. */ /** Tablica zmiennej długości zawierająca wartości int. */
class Wektor { class Wektor {
int t[10];
// logiczny rozmiar wektora = ile pozycji w tablicy jest zajętych = indeks pierwszej wolnej pozycji
int liczba_elementow;
public: public:
Wektor(); 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