I have a class :
class InterruptDevice { public: InterruptDevice(); InterruptDevice(USHORT deviceAddress); ~InterruptDevice(); USHORT deviceAddress; bool obsolete; std::map<USHORT, std::vector<HIDReportDescriptorInputParse>> inputparser; std::map<BYTE, std::vector<BYTE>> endpoints;T }; where HIDReportDescriptorInputParse is struct :
typedef struct HIDReportDescriptorInputParse { HIDReportDescriptorInputParse() : inputSize(0), reportDefined(false), reportID(0), deviceAddress(0), globalItemUsage(0), localItemUsage(0) { } int inputSize; bool reportDefined; uint32_t reportID; uint32_t globalItemUsage; uint32_t localItemUsage; USHORT deviceAddress; std::vector<InputValues> inputValues; } HIDReportDescriptorInputParse, * PHIDReportDescriptorInputParse; typedef struct InputValues { InputValues() : GlobalUsagePage(0), ReportSize(0), ReportCount(0), UsageMinimum(0), UsageMaximum(0), LogicalMinimum(0), LogicalMaximum(0), Variable(true) { } std::vector<uint32_t> LocalUsageNames; uint32_t GlobalUsagePage; uint32_t ReportSize; uint32_t ReportCount; uint32_t UsageMinimum; uint32_t UsageMaximum; uint32_t LogicalMinimum; uint32_t LogicalMaximum; bool Variable; }InputValues, * PInputValues; Now, I want to have a class which takes InterruptDevice as a constructor argument, but I dont want it to be mandatory, so I need default argument value. Can it be written like this :
class A { public: A(int a, InterruptDevice device = InterruptDevice()); } When I try this, it works, but I am afraid of some undefined behaviour. Is this correct way how to do this ?
~InterruptDevice()so you have to respect rule of 3/5).