I require help with respect to class construction. In my class, I have used a copy constructor and operator= to prevent the compiler from creating them. In my main program, when I try to create an instance of the class, I get an error saying “No default constructor exists for the class”.
What could be the problem?
This is a snippet of my code.
class netlist {
netlist(const netlist &);
netlist &operator=(const netlist &);
std::map<std::string, net *> nets_;
}; // class netlist
In my main function I am using:
netlist nl;
This is where I get the error. I am providing the copy constructor declaration, so they should not be a problem.
I would appreciate any help with this. Thanks in advance.
There are two problems with the code –
"I get an error saying "No default constructor exists for the class" ".Because if any kind of constructor is provided as a part of class declaration(
netlistclass has a copy constructor in this case), default constructor( i.e., constructor with no arguments ) is not provided by compiler.netlist.h
netlist.cpp