Magical Mystery constructor?
Why is this array initialization legal? The array type is Part. Granted, the components inside the brackets are of the correct types for a Part, but no Part has been constructed, and there is no 2-argument constructor for Part anyway.
Code:
#include <iostream>
#include <string>
using namespace std;
const int SIZE=5;
struct Part {
string partNo;
double cost;
};
int main()
{
Part parts[SIZE] =
{
{"X-101",7.50},
{"XY-2.04",4.75}
};
cout << parts[0].partNo << endl;
cout << parts[0].cost << endl;
}