2024-05-28 07:41:33 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
2024-05-28 05:59:31 +00:00
|
|
|
/*class GBaseShape {
|
|
|
|
public:
|
|
|
|
GBaseShape();
|
|
|
|
virtual void EvalVolume();
|
|
|
|
virtual void EvalSurface();
|
|
|
|
double GetVolume() const;
|
|
|
|
double GetVolume() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
double Volume, Surface;
|
|
|
|
bool IfVolumeCalculated;
|
|
|
|
bool IfSurfaceCalculated;
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Cube {
|
|
|
|
public:
|
2024-05-28 07:41:33 +00:00
|
|
|
explicit Cube(double _L = 0, double _W = 0, double _H = 0, long int N = 0);
|
|
|
|
~Cube(){
|
|
|
|
// std::cout << "Destructor was run!\n";
|
|
|
|
delete Data;
|
|
|
|
}
|
2024-05-28 05:59:31 +00:00
|
|
|
// void SetAll();
|
|
|
|
void SetL(double _L);
|
2024-05-28 07:41:33 +00:00
|
|
|
|
2024-05-28 05:59:31 +00:00
|
|
|
// void SetB(double _B);
|
|
|
|
// void SetC(double _C);
|
2024-05-28 07:41:33 +00:00
|
|
|
|
2024-05-28 05:59:31 +00:00
|
|
|
const double& GetL();
|
2024-05-28 07:41:33 +00:00
|
|
|
double& operator[] (int i){
|
|
|
|
if(i==1)
|
|
|
|
return L;
|
|
|
|
if (i==2)
|
|
|
|
return W;
|
|
|
|
if (i==3)
|
|
|
|
return H;
|
|
|
|
return tmp;
|
|
|
|
}
|
2024-05-28 05:59:31 +00:00
|
|
|
private:
|
|
|
|
double L,W,H;
|
2024-05-28 07:41:33 +00:00
|
|
|
double* Data;
|
|
|
|
double tmp;
|
2024-05-28 05:59:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2024-05-28 07:41:33 +00:00
|
|
|
Cube::Cube(double _L , double _W , double _H, long int N ){
|
2024-05-28 05:59:31 +00:00
|
|
|
SetL(_L);
|
2024-05-28 07:41:33 +00:00
|
|
|
Data = new double[N];
|
|
|
|
//std::cout << "Constructor was run!\n";
|
2024-05-28 05:59:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Cube::SetL(double _L){
|
|
|
|
L = _L;
|
|
|
|
}
|
|
|
|
|
|
|
|
const double& Cube::GetL() {
|
|
|
|
return L;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(){
|
2024-05-28 07:41:33 +00:00
|
|
|
|
|
|
|
Cube cube(5,6,10);
|
|
|
|
|
|
|
|
//cube.GetL()++;
|
|
|
|
// for (int i{0}; i<10000; i++)
|
|
|
|
// {
|
|
|
|
// auto c = Cube(0,0,0,1000000);
|
|
|
|
// }
|
|
|
|
//for (int i{0}; i<10000000000; i++)
|
|
|
|
// std::cout << "!!!\n";
|
2024-05-28 05:59:31 +00:00
|
|
|
|
2024-05-28 07:41:33 +00:00
|
|
|
std::cout << cube[1] << "\n";
|
2024-05-28 05:59:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|