diff options
author | Oskar <[email protected]> | 2024-07-31 17:09:45 +0200 |
---|---|---|
committer | Oskar <[email protected]> | 2024-07-31 17:09:45 +0200 |
commit | a450487a18ec72ea3a3815bfaf17b2f701796b6f (patch) | |
tree | 67b4cfe127bc5c134f06c06e57ad35629e630b7b /auto-test.cpp | |
parent | b7819b597e1241dd98643eeda4c288a341142311 (diff) |
more
Diffstat (limited to 'auto-test.cpp')
-rw-r--r-- | auto-test.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/auto-test.cpp b/auto-test.cpp new file mode 100644 index 0000000..919e1e4 --- /dev/null +++ b/auto-test.cpp @@ -0,0 +1,30 @@ +#include <iostream> +#include "sales_item.hpp" + +/* + * + * testing with auto + * + * + */ + +int main () { + + double ff = 3.14; + auto i = 0, *p = &i; + auto i2 = 0.0, i3 = ff; + std::cout << i << " " << *p << " " << i2 << " " << i3 << std::endl; + const int gg = 66; + const auto pgg = ≫ // if we want toplevel const then we have to say it before auto + std::cout << gg << " <gg\n" << *pgg << " <*pgg" << std::endl; + std::cout << &gg << " <&gg\n" << pgg << " <pgg" << std::endl; + + int ci = 99; + auto &g = ci; + const auto &j = 42; // ok: we can bind a const reference to a literal + std::cout << g << " <g\n" << j << " <j" << std::endl; + g += 1; + //j += 1; // Not possible + std::cout << g << " <g\n" << j << " <j" << std::endl; + return 0; +} |