I just thought, incorrectly it turns out, that C++ structs were somehow fundamentally different than C structs and required a (usually default) constructor.
This means that the same thing can be done to instantiate a class member if all member variables are public. I've certainly never seen that before either, but it works:
Code:
#include <iostream>
#include <string>
using namespace std;
const int SIZE=5;
class Part {
public:
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;
Part part1 = {"abc", 1.23};
cout << part1.cost <<endl;
}