By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,194 Members | 811 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,194 IT Pros & Developers. It's quick & easy.

Vector of structures: non-aggregate error

P: n/a
Dear cpp-ians,

I have a vector of structures:

struct meta_group
{
float id;
float num;
float mean;
float sum;
float sumofsquares;
float std;
struct pixel * head;
struct pixel * tail;
struct pixel * edge_head;
struct pixel * edge_tail;
bool full;
};

vector<meta_group> meta_segment[sizeI[2]];
vector<meta_group>::iterator it_meta_segment;

And now I want to assign values to the elements of this vector by:

for( it_meta_segment = meta_segment.begin(); it_meta_segment!=
meta_segment.end(); it_meta_segment++ ) {
int i = floor((it_meta_segment)/sizeI[0]);
int j = fabs((it_meta_segment)/sizeI[0]);
meta_segment[it_meta_segment].id = it_meta_segment;
meta_segment[it_meta_segment].num = 1;
meta_segment[it_meta_segment].mean = output[i][j]->value;
....
}

When I compile this I get the following errors:

* request for member `begin' in `meta_segment', which is of
non-aggregate type
* request for member `end' in `meta_segment', which is of
non-aggregate type

What do I do wrong that the begin() and end() do not work. What do I
have to add to solve this problem?

Thanx in advance!

Kind regards,
Stef

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
koperenkogel wrote:
Dear cpp-ians,

I have a vector of structures:

struct meta_group
{
float id;
float num;
float mean;
float sum;
float sumofsquares;
float std;
struct pixel * head;
struct pixel * tail;
struct pixel * edge_head;
struct pixel * edge_tail;
bool full;
};

vector<meta_group> meta_segment[sizeI[2]];


Do you really mean to create an array of vectors? ITYM:

vector<meta_group> meta_segment( sizeI[2] );
Jul 23 '05 #2

P: n/a
Indeed, stupid of me.
I was already looking at it for a long time. Too long it seems.

Thank you ,
Stef

Jul 23 '05 #3

P: n/a
koperenkogel wrote:

[...]
When I compile this I get the following errors:

* request for member `begin' in `meta_segment', which is of
non-aggregate type
* request for member `end' in `meta_segment', which is of
non-aggregate type

What do I do wrong that the begin() and end() do not work. What do I
have to add to solve this problem?
Your /meta_segment/ variable is not a std::vector. It is declared as an
array of std::vector and, therefore, cannot have /begin()/ invoked on it.
vector<meta_group> meta_segment[sizeI[2]];


You should have written:

vector<meta_group> meta_segment(sizeI[2]);

Regards,

--
Ney André de Mello Zunino
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.