'Error C2440: 'initializing': cannot convert from 'initializer list' to struct
VA2022 (17.0.6), Windows 10 x64.
When I build the C++ pgm below (debug build), I get an error message
C20vsC17.cpp(18,4): error C2440: 'initializing': cannot convert from 'initializer list' to 'main::V'
C20vsC17.cpp(19,2): message : No constructor could take the source type, or constructor overload resolution was ambiguous
What is the reason for this error?
#include <iostream>
int main()
{
struct V
{
char name[25];
void *pValue;
V(char *nameIn, void *pValueIn)
{
strcpy_s(name, nameIn); pValue = pValueIn;
}
};
V var[] =
{
{ "Name", nullptr }
};
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
