Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: linearArray.hpp
- Revision:
- 2:92576523c23e
- Parent:
- 1:49758f1e1317
- Child:
- 3:8e9f85814809
- Child:
- 9:68d882e457c5
diff -r 49758f1e1317 -r 92576523c23e linearArray.hpp
--- a/linearArray.hpp Tue Oct 04 13:38:07 2016 +0000
+++ b/linearArray.hpp Wed Oct 05 09:35:55 2016 +0000
@@ -1,7 +1,7 @@
template <class type>
-LinearArray<type>::LinearArray(int size): elem_count(0) {
+LinearArray<type>::LinearArray(int size): elem_count(0), array_size(size) {
array = new type[size];
}
@@ -12,6 +12,7 @@
template <class type>
int LinearArray<type>::add(type item) {
+
int ret = -1;
if (hasSpace()) {
array[elem_count] = item;
@@ -36,7 +37,7 @@
template <class type>
int LinearArray<type>::size() {
- return sizeof(array);
+ return array_size;
}
template <class type>
@@ -46,7 +47,7 @@
template <class type>
bool LinearArray<type>::hasSpace() {
- return elem_count < sizeof(array);
+ return elem_count < array_size;
}
template <class type>