c-resources/CPlusPlus20ForProgrammers-m.../examples/vector/shapes_defaultConstructor.cpp

40 lines
705 B
C++
Raw Normal View History

2024-06-10 10:43:07 +00:00
#include "shapes_defaultConstructor.h"
double& Cube::operator() (int i){
try {
if(i==1)
return L;
if (i==2)
return W;
if (i==3)
return H;
if (i<1 || i > 3)
throw(i);
}
catch(int i){
std::cout << "out of index" << i << "\n";
exit(0);
}
return tmp;
}
Cube::Cube(double _L , double _W , double _H, long int _N ):N(_N){
SetL(_L);
Data = new double[N];
Data[0] = _L;
//std::cout << "Constructor was run!\n";
}
void Cube::SetL(double _L){
L = _L;
}
const double& Cube::GetL() {
return L;
}