How can insert value in structure vector?

Here I have given my sample code, but it gave error. How can insert value in structure vector?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
struct Hough_Transform_3D_Accumulator
{
	long int i;
	long int j;
	long int k;
	long int count;
};

int main()
{
........................

for(i=0;i<total_r_count;i++)//for loop r count start
{
for(j=0;j<total_theta_count;j++)//for loop theta count start
{
for(k=0;k<total_shi_count;k++)//for loop shi count start
{
if(accumulator_3D[i][j][k]>0)
{
vec.push_back(i,j,k,accumulator_3D[i][j][k]);/// error message
}
}
}
}


Error Message:error C2661: 'std::vector<_Ty>::push_back' : no overloaded function takes 4 arguments
- Would you mid posting the rest of your code?

- I'm not exactly sure where you defined "vec" or "accumulator_3D",etc.
You can only pass one argument to push_back() at a time. If you want to push each of those things back into the vector, call push_back() multiple times. Otherwise, just call it once for the one thing you want to add to the vector.
- Additionally, if your vector (assuming that you defined it somewhere else in your code as i can't see the definition) is of type "long int", you can't push back a "Hough_Transform_3D_Accumulator" type to it.

- This is because you have already specified the data type you are using for the vector template. Hence, "vector<dataType> variableName".

- Ex, if you declare "vector<int> ints",\ and " double b", attempting "ints.push_back(b)" will result in an error.
I solved the problem. Here is the solution.

Hough_Transform_3D_Accumulator mystruct;

mystruct.i = 1;

mystruct.j = 2;

mystruct.k = 3;

mystruct.count = 3;

vec.push_back(mystruct); //<-- Add our newly filled structure to the vector
- That method would also work.
Topic archived. No new replies allowed.