473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Vector of structures: non-aggregate error

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
3 1939
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: luigi | last post by:
Hi, I am trying to speed up the perfomance of stl vector by allocating/deallocating blocks of memory manually. one version of the code crashes when I try to free the memory. The other version...
3
by: Duncan | last post by:
I need to populate a vector with the following struct details:\ struct group { string groupname; int gid; list<string> members; }; the text file which this is to read from is in the...
13
by: Joseph | last post by:
I was doing my assignment,but encountered a problem at last step!!!!!! for easy reading, i ommited lots of other things //=====================code begin================================...
8
by: Hamish | last post by:
I havea program which on execution gives unpredictable behaviour (it shouldn't). In trying to track down the problem, I'm wondering if there is a difference between these two ways of filling a...
11
by: koperenkogel | last post by:
Dear cpp-ians, I am working with a vector of structures. vector <meta_segment> meta_segm (2421500); and the structure look like: struct meta_segment { float id; float num;
10
by: repairman2003 | last post by:
Considering this struct: typedef struct ServiceRecord { vector<string> service; vector<Date> date; } ServiceRecord; Date is declared elsewhere as:
2
by: sd2004 | last post by:
Hi, there is "array of structures" Is there anything likes "vector of structures" in C++ ? Please give me one example.
12
by: y-man | last post by:
Hi, I am creating a child class of the vector, which contains a couple of functions to make the work with carthesian coordinate vectors easier. To make things work more easily, I would like to...
2
by: jeff_j_dunlap | last post by:
I recently began using STL containers, mainly to store pointers to structures using a vector: std::vector <dataStruc*vdata; Next, I fill the container within a loop: vdata.push_back(new...
4
by: Tony | last post by:
Hello, For my application, I have a vector containing data that I need, vector<NODEnode_data; and I have a pointer of vectors which are sorted by some criterion as vector<NODE*np. I have planned...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.