diff --git a/CM2005 Object Oriented Programming/Topic 2/2.6.1/Vec3D.cpp b/CM2005 Object Oriented Programming/Topic 2/2.6.1/Vec3D.cpp new file mode 100644 index 0000000..25defc8 --- /dev/null +++ b/CM2005 Object Oriented Programming/Topic 2/2.6.1/Vec3D.cpp @@ -0,0 +1,7 @@ +#include +#include "Vec3D.h" + +int Vec3D::getLength() +{ + return std::sqrt((x*x + y*y + z*z)); +} \ No newline at end of file diff --git a/CM2005 Object Oriented Programming/Topic 2/2.6.1/Vec3D.h b/CM2005 Object Oriented Programming/Topic 2/2.6.1/Vec3D.h new file mode 100644 index 0000000..c63183c --- /dev/null +++ b/CM2005 Object Oriented Programming/Topic 2/2.6.1/Vec3D.h @@ -0,0 +1,12 @@ +#pragma once + +class Vec3D +{ + public: + int getLength(); + int x; + int y; + int z; + private: + int size = 3; +}; \ No newline at end of file diff --git a/CM2005 Object Oriented Programming/Topic 2/2.6.1/a.exe b/CM2005 Object Oriented Programming/Topic 2/2.6.1/a.exe new file mode 100644 index 0000000..34a41fd Binary files /dev/null and b/CM2005 Object Oriented Programming/Topic 2/2.6.1/a.exe differ diff --git a/CM2005 Object Oriented Programming/Topic 2/2.6.1/test.cpp b/CM2005 Object Oriented Programming/Topic 2/2.6.1/test.cpp new file mode 100644 index 0000000..d894151 --- /dev/null +++ b/CM2005 Object Oriented Programming/Topic 2/2.6.1/test.cpp @@ -0,0 +1,27 @@ +#include +#include +#include +#include +#include "Vec3D.h" + +Vec3D vec1; + +void doSomething() +{ + vec1.x = 10; + vec1.y = 12; + vec1.z = 25; +} + +int main() +{ + doSomething(); + + //std::cout << vec1.x << std::endl; + //std::cout << vec1.size << std::endl; + std::vector coords; + coords.push_back(vec1); + //std::cout << coords[0].x << std::endl; + std::cout << coords[0].getLength() << std::endl; + return 0; +} \ No newline at end of file