Hello!
I'm having some problems with constructor initialization,mainly because I have object members and vectors within classes.
I have a class Factory in which i have 2 object members(base and dumpster),a vector of Floors and a set of Robots.
Each Floor has a size(lin,col) and a member object Cell which represents the cells in a given floor
I want to be able to initialize the Factory upon it's creation with the parameters on the constructor below.
The problem is: I want to construct the Factory with a certain number of floors(say 2 floors).How do I do that in the constructor?
I also want to initialize each floor with cells(each cell occupies a 1x2 space upon the construction of the Factory,based on the linxcol of the floor.How do I do that?My current Factory initialization is declared on main like this: Factory f(floors(lin,col,cell(x,y,residue(quant))),robots,dumpster(lposxx,lposyy),base(bposxx,bposyy));
I think this is only initializing one floor with one cell,but I want it to initialize it as described above!
Here are the classes:
class Fabrica
{
private:
int trackCurrentFloor=0;
vector<Floor> floors;
set<Robot> robots;
Dumpster dumpster;
Base base;
public:
Factory(vector<Floor> floors,set<Robot> robots,Dumpster dumpster,Base base);
...
}
class Residue
{
private:
int quantity=0;
...
}
class [B]Floor[/B]
{
private:
int lin;
int col;
Cell cell;
}
class Cell
{
private:
vector<Residue> residues;
int xx;
int yy;
}
class [B]Dumpster[/B]
{
private:
int x;
int y;
}
class [B]Base[/B]
{
private:
int x;
int y;
}
class [B]Robot[/B]
{
private:
int x;
int y;
...
}
void [B]main[/B]()
{
...
Factory f(floors(lin,col,cell(x,y,residue(quant))),robots,dumpster(lposxx,lposyy),base(bposxx,bposyy));
...
}
Thanks in advance for the reply!