diff options
author | Nao Pross <naopross@thearcway.org> | 2018-12-08 12:58:04 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-12-08 12:58:04 +0100 |
commit | 05f2df34290af477b0fee49b75e5f56e1d6c83f9 (patch) | |
tree | 66a7214321c874be02d1a4a9b4fd3f489dc09ad8 /template.cpp | |
download | cplusplus-05f2df34290af477b0fee49b75e5f56e1d6c83f9.tar.gz cplusplus-05f2df34290af477b0fee49b75e5f56e1d6c83f9.zip |
Initial commit with kinda crappy unnumbered examples
Diffstat (limited to '')
-rw-r--r-- | template.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/template.cpp b/template.cpp new file mode 100644 index 0000000..e67645b --- /dev/null +++ b/template.cpp @@ -0,0 +1,23 @@ +#include <iostream> + +template<typename T> +struct vec3 { + T x; + T y; + T z; +}; + +template<typename T> +int dot(vec3<T> v, vec3<T> u) { + return v.x * u.x + v.y * u.y + v.z * u.z; +} + +int main(int argc, char *argv[]) { + + vec3<int> v = {1, 2, 3}; + vec3<int> u = {1, 2, 3}; + + std::cout << dot(v, u) << std::endl; + + return 0; +} |