From e9495844291a85a1f7ba3c76742a0dd1bf574e5f Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 10 Oct 2018 10:15:49 +0200 Subject: hosted gcc compiler --- userspace/cpp/Makefile | 6 ++++++ userspace/cpp/testcpp.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 userspace/cpp/Makefile create mode 100644 userspace/cpp/testcpp.cpp (limited to 'userspace/cpp') 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 +#include +#include +#include + +//#undef _REENT_GLOBAL_STDIO_STREAMS + +int main() +{ + _REENT_INIT_PTR(_impure_ptr); + + + + + // constructors used in the same order as described above: + std::vector first; // empty vector of ints + std::vector second (4,100); // four ints with value 100 + std::vector third (second.begin(),second.end()); // iterating through second + std::vector 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 fifth (myints, myints + sizeof(myints) / sizeof(int) ); + + std::cout << "The contents of fifth are:"; + for (std::vector::iterator it = fifth.begin(); it != fifth.end(); ++it) + std::cout << ' ' << *it; + std::cout << '\n'; + + + + return 0; +} -- cgit v1.2.3