I have a running program in c++ where I am dealing with multiple functions, and I am trying to convert program onto an implementation in which constructors can be used. Program looks like below
bool netlist::create(const evl_wires &wires,
const evl_components &comps)
{
return create_nets(wires)&& create_gates(comps);
}
netlist::netlist(const evl_wires &wires,
const evl_components &comps)
{
create(wires, comps);
}
where in main function I am calling constructor successfully like this
netlist nl(wires, comps);
Change I am trying to implement looks like this by adding more constructors
netlist::netlist(const evl_components &comps)
{
create_gates(comps);
}
netlist::netlist(const evl_wires &wires)
{
create_nets(wires);
}
netlist::netlist(const evl_wires &wires,
const evl_components &comps)
{
//this->netlist::netlist(wires);//this approach doesn't work
//this->netlist::netlist(comps);
*this = netlist::netlist(wires);//it doesn't work too
*this = netlist::netlist(comps);
}
Examples given on internet websites including this one just show how to call one constructor inside another, how can we call multiple constructors inside one for my example? Other question is when implementation with constructors is better than implementation without constructors keeping in view of my program code?