I've been working on a C++ exercise and I was unable to figure out how to do it correctly, let me explain it:
I made this class based on the 1st question of the exercise
class cylinder
{
private:
float height;
float radius;
char * label;
public:
cylinder(float, float, char *);
cylinder();
cylinder(const cylinder &);
~cylinder();
};
The 2nd question was:
Create a new class "form3D" contain cylinders (dynamic array of cylinder)
How to make a default constructor & constructor with parameters?
This is what I did:
class forme3d
{
cylinder * tab;
int tabsize;
public:
forme3d();
forme3d(cylinder * , int);
~forme3d();
};
forme3d::forme3d(cylindre * c, int t)
{
cylindre * tab = new cylindre[t];
for (int i = 0; i < t; ++i)
{
tab[i] = c[i];
}
}
This cause an error about "operator=" not defined for this line "tab[i] = c[i];"