diff --git a/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/Shapes.h b/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/Shapes.h new file mode 100644 index 0000000..4d22884 --- /dev/null +++ b/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/Shapes.h @@ -0,0 +1,46 @@ +#include +#include +#include +class Cube { + + public: + Cube(){} + Cube(auto _A, auto _B, auto _C): A(_A), B(_B), C(_C){ + } +public: +double EvalVolume(){ + return A * B * C; +} +std::array GetAll(){ + auto tmp {std::array()}; + tmp[0]=A; + tmp[1]=B; + tmp[2]=C; + return tmp; +} +void SetAll(auto _A, auto _B, auto _C){ + A=_A; + B=_B; + C=_C; +} +void SetA(double x){ + A=x; +} +void SetB(double x){ + B=x; +} +void SetC(double x){ + C=x; +} +const double& GetA(){ + return A; +} +const double& GetB(){ + return B; +} +const double& GetC(){ + return C; +} +private: + double A, B, C, Volume; +}; \ No newline at end of file diff --git a/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/a.out b/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/a.out new file mode 100755 index 0000000..c5c5505 Binary files /dev/null and b/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/a.out differ diff --git a/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/main.cpp b/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/main.cpp new file mode 100644 index 0000000..06513f6 --- /dev/null +++ b/CPlusPlus20ForProgrammers-master/examples/Shapes/dd/main.cpp @@ -0,0 +1,17 @@ +#include "Shapes.h" + +int main(){ + Cube c; + Cube c2(1,4,6); + + std::vector Cubes; + Cubes.push_back(c); + Cubes.push_back(c2); + Cubes.push_back(Cube(6,8,9)); + + for ( auto x : Cubes){ + std::cout << x.EvalVolume() << "\n"; + } + + return 0; +} \ No newline at end of file