Vector of structures: non-aggregate error

Discussion in 'C++' started by koperenkogel, Mar 24, 2005.

  1. koperenkogel

    koperenkogel Guest

    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[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
     
    koperenkogel, Mar 24, 2005
    #1
    1. Advertising

  2. koperenkogel

    Jeff Schwab Guest

    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] );
     
    Jeff Schwab, Mar 24, 2005
    #2
    1. Advertising

  3. koperenkogel

    koperenkogel Guest

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

    Thank you ,
    Stef
     
    koperenkogel, Mar 24, 2005
    #3
  4. 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
     
    =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?=, Mar 24, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles Jamieson

    non-aggregate error

    Charles Jamieson, Jul 13, 2004, in forum: C++
    Replies:
    6
    Views:
    510
    Old Wolf
    Jul 14, 2004
  2. Alfonso Morra
    Replies:
    11
    Views:
    752
    Emmanuel Delahaye
    Sep 24, 2005
  3. Replies:
    8
    Views:
    1,998
    Csaba
    Feb 18, 2006
  4. Alden Pierre
    Replies:
    3
    Views:
    362
    Ben Pope
    Apr 5, 2006
  5. rickman
    Replies:
    5
    Views:
    460
    rickman
    Mar 30, 2013
Loading...

Share This Page