Compare commits

..

2 Commits

Author SHA1 Message Date
davoudn cd0405b0c2 Merge branch 'master' of http://5.34.202.199:3000/davoudn/c-resources 2024-05-28 09:38:46 +03:30
davoudn 9ee80bc2eb shapes change 2024-05-28 09:36:28 +03:30
3 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#include <iostream>
#include <array>
#include <vector>
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<double, 3> GetAll(){
auto tmp {std::array<double, 3>()};
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;
};

Binary file not shown.

View File

@ -0,0 +1,17 @@
#include "Shapes.h"
int main(){
Cube c;
Cube c2(1,4,6);
std::vector<Cube> 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;
}