summaryrefslogtreecommitdiff
path: root/userspace/cpp
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-10 10:15:49 +0200
committerMiguel <m.i@gmx.at>2018-10-10 10:15:49 +0200
commite9495844291a85a1f7ba3c76742a0dd1bf574e5f (patch)
treea0d2ba779ed8e471758a77745250731a1596182b /userspace/cpp
parent63e5017d9863d4ed215782e469e8ee2c6ff8473d (diff)
hosted gcc compiler
Diffstat (limited to 'userspace/cpp')
-rw-r--r--userspace/cpp/Makefile6
-rw-r--r--userspace/cpp/testcpp.cpp34
2 files changed, 40 insertions, 0 deletions
diff --git a/userspace/cpp/Makefile b/userspace/cpp/Makefile
new file mode 100644
index 0000000..7623325
--- /dev/null
+++ b/userspace/cpp/Makefile
@@ -0,0 +1,6 @@
+CXX=i686-foolos-g++
+
+testcpp:
+
+clean:
+ rm -f testcpp
diff --git a/userspace/cpp/testcpp.cpp b/userspace/cpp/testcpp.cpp
new file mode 100644
index 0000000..0e89276
--- /dev/null
+++ b/userspace/cpp/testcpp.cpp
@@ -0,0 +1,34 @@
+// constructing vectors
+#include <iostream>
+#include <vector>
+#include <cstring>
+#include <reent.h>
+
+//#undef _REENT_GLOBAL_STDIO_STREAMS
+
+int main()
+{
+ _REENT_INIT_PTR(_impure_ptr);
+
+
+
+
+ // constructors used in the same order as described above:
+ std::vector<int> first; // empty vector of ints
+ std::vector<int> second (4,100); // four ints with value 100
+ std::vector<int> third (second.begin(),second.end()); // iterating through second
+ std::vector<int> fourth (third); // a copy of third
+
+ // the iterator constructor can also be used to construct from arrays:
+ int myints[] = {16,2,77,29};
+ std::vector<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
+
+ std::cout << "The contents of fifth are:";
+ for (std::vector<int>::iterator it = fifth.begin(); it != fifth.end(); ++it)
+ std::cout << ' ' << *it;
+ std::cout << '\n';
+
+
+
+ return 0;
+}