0

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 by kirennian: n/a

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by kirennian
Featured Replies
  • he doesn't like: [CODE]vector<int[3]> resolutions;[/CODE] should be: [CODE]vector<int> resolutions;[/CODE] if you need an array: [CODE]vector<list<int>> resolutions;[/CODE] Read More

0

did you try:

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

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.

1

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.
0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.