This commit is contained in:
davoudn 2024-05-28 11:11:33 +03:30
parent cd0405b0c2
commit c0f971c2ed
2 changed files with 34 additions and 6 deletions

View File

@ -1,4 +1,5 @@
#include <iostream>
#include <vector>
/*class GBaseShape {
public:
GBaseShape();
@ -19,20 +20,38 @@ double GetVolume() const;
class Cube {
public:
explicit Cube(double _L = 0, double _W = 0, double _H = 0);
explicit Cube(double _L = 0, double _W = 0, double _H = 0, long int N = 0);
~Cube(){
// std::cout << "Destructor was run!\n";
delete Data;
}
// void SetAll();
void SetL(double _L);
// void SetB(double _B);
// void SetC(double _C);
const double& GetL();
double& operator[] (int i){
if(i==1)
return L;
if (i==2)
return W;
if (i==3)
return H;
return tmp;
}
private:
double L,W,H;
double* Data;
double tmp;
};
Cube::Cube(double _L , double _W , double _H ){
Cube::Cube(double _L , double _W , double _H, long int N ){
SetL(_L);
Data = new double[N];
//std::cout << "Constructor was run!\n";
}
void Cube::SetL(double _L){
@ -44,9 +63,18 @@ const double& Cube::GetL() {
}
int main(){
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";
Cube cube(5);
cube.GetL()++;
std::cout << cube[1] << "\n";
return 0;
}