Hi there.

I'm currently attempting to create a vector of structs whereby the struct itself contains a vector. The problem I am having is upon creation of the struct itself, throwing the following error.

error:C2075: 'Target of operator new()' : array initialization needs curly braces.

struct DISPLAY_DEVICE_CAPABILITIES{
	vector<int[3]> resolutions;
	int brightness;
};

vector<DISPLAY_DEVICE_CAPABILITIES> displays;

DISPLAY_DEVICE_CAPABILITIES newDisplay;
displays.insert(displays.begin(), newDisplay);

I have tried using push_back instead to no avail; the error remains the same. Does anyone have any ideas of how to alleviate this problem? Sadly it's not an easily googleable issue...vector of structs containing a vector, heh.

Any help would be greatly appreciated... thanks for your time :)


edit:argh, typo in the thread title...how annoying :(

Edited 7 Years Ago by kirennian: n/a

did you try:

typedef struct DISPLAY_DEVICE_CAPABILITIES{
	vector<int[3]> resolutions;
	int brightness;
}DISPLAY_DEVICE_CAPABILITIES;

did you try:

typedef struct DISPLAY_DEVICE_CAPABILITIES{
	vector<int[3]> resolutions;
	int brightness;
}DISPLAY_DEVICE_CAPABILITIES;

It comes up with:

error C2923: 'std::vector' : DISPLAY_DEVICE_CAPABILITIES' is not a valid template type argument for parameter '_Ty' x7 unfortunately :(

It doesn't like the vector declaration in the header file.

he doesn't like:

vector<int[3]> resolutions;

should be:

vector<int> resolutions;

if you need an array:

vector<list<int>> resolutions;
Comments
Problem solved, thanks.

if you need an array:

vector<list<int>> resolutions;

Thanks mate, it worked. Will work out the intricacies(sp?) from this. :)

This question has already been answered. Start a new discussion instead.