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 :(

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;
commented: Problem solved, thanks. +1

if you need an array:

vector<list<int>> resolutions;

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.