Basically, I have a class called VisaMux and a class called MuxPath. MuxPath has a VisaMux private instance variable. I want MuxPath's constructor to assign the instance variable a given VisaMux object without invoking an empty VisaMux() constructor.
5 MuxPath::MuxPath(const uint& Clk_sel, const uint& Lane_sel, const VisaMux& Mux){
6 clk_sel = Clk_sel;
7 lane_sel = Lane_sel;
8 mux = Mux;
9 }
This code results in the error:
MuxPath.cpp:5: error: no matching function for call to ‘VisaMux::VisaMux()’
VisaMux.h:20: candidates are: VisaMux::VisaMux(const std::string&, const uint&, const uint&, const std::vector<VisaLane, std::allocator<VisaLane> >&, const std::vector<VisaResource, std::allocator<VisaResource> >&)
As you can see, it errors on the first line (line 5), so it seems that somehow const VisaMux& Mux is invoking VisaMux(), which doesn't exist. This also happens if I just do VisaMux Mux.
I don't want it to call an empty constructor for VisaMux because I want VisaMux to be created only by passing its constructor all the necessary parameters.
How can I do this?