c++ “no matching function for call to” error with structure

前端 未结 2 547
一整个雨季
一整个雨季 2020-12-21 13:07

I have C++ code that maps GUID(unsigned long) to structure.

#include 
#include 
#include 

typedef unsigned long GU         


        
2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-21 13:23

    Any objects you place in a STL container initialized with an initial number of objects (i.e., you're not initializing an empty container) must have at least one default constructor ... yours does not. In other words your current constructor needs to be initialized with specific objects. There must be one default constructor that is like:

    PluginInfo();
    

    Requiring no initializers. Alternatively, they can be default initializers like:

    PluginInfo(GUID _guid = GUID(), 
               std::string _name = std::string(), 
               Function _function = Function()): 
               guid(_guid), name(_name), function(_function) {}
    

提交回复
热议问题