-
June 26th, 2013, 01:17 AM
#1
Nested vector initialization problem
Hello,
I initialized a nested vector with the following code as:
Code:
vector<vector<Point> > vectorB(4, vector<Point> (int(vectorA.size()), 0));
And came across the following error during link stage:
"/usr/include/c++/4.6/bits/stl_vector.h:1080:4: error: no matching function for call to ‘std::vector<cv::Point_<int> >::_M_fill_initialize(std::vector<cv::Point_<int> >::size_type, int&)’ "
Please kindly suggest. Thank you.
Eric
Last edited by Ericxx; June 26th, 2013 at 01:27 AM.
-
June 26th, 2013, 02:22 AM
#2
Re: Nested vector initialization problem
I doubt it would make a difference here, but you should remove that unnecessary cast to int, i.e.,
Code:
vector<vector<Point> > vectorB(4, vector<Point> (vectorA.size(), 0));
If that does not work, post the smallest and simplest program that you expect to compile but which results in the error. After all, your examples does not define Point or vectorA.
-
June 26th, 2013, 07:09 AM
#3
Re: Nested vector initialization problem
Originally Posted by laserlight
I doubt it would make a difference here, but you should remove that unnecessary cast to int, i.e.,
Code:
vector<vector<Point> > vectorB(4, vector<Point> (vectorA.size(), 0));
If that does not work, post the smallest and simplest program that you expect to compile but which results in the error. After all, your examples does not define Point or vectorA.
Thank you. I have tried without the casting. But still got the error. As you suggested, a smalll program is listed below. The environment is Ubuntu 12.04. Wondering if this is a c++ library issue...
Code:
#include <stdio.h>
#include <vector>
struct Point {
double x,y;
};
int main(int argc, char* argv[])
{
std::vector<std::vector<Point> > nestVector (4, std::vector<Point>(4,0));
printf("Nested vector test\n");
return 0;
}
-
June 26th, 2013, 07:19 AM
#4
Re: Nested vector initialization problem
See the "0" in red below.
Code:
std::vector<std::vector<Point> > nestVector (4, std::vector<Point>(4,0));
The argument should be of type Point, not int ..
Code:
std::vector<std::vector<Point> > nestVector (4, std::vector<Point>(4,Point()));
-
June 26th, 2013, 10:06 AM
#5
Re: Nested vector initialization problem
Originally Posted by Ericxx
The environment is Ubuntu 12.04.
That is an OS, not a compiler. You need to tell us the compiler and compiler version you're using.
Second, that line yields a compiler error, while your original post states a linker error.
And came across the following error during link stage:
"/usr/include/c++/4.6/bits/stl_vector.h:1080:4: error: no matching function for call to ‘std::vector<cv::Point_<int> >::_M_fill_initialize(std::vector<cv::Point_<int> >::size_type, int&)’ "
That is not a linker error, that is a compiler error.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; June 26th, 2013 at 10:12 AM.
-
June 27th, 2013, 05:17 AM
#6
Re: Nested vector initialization problem
Thanks Philip. The problem has already been solved.
-
June 27th, 2013, 05:20 AM
#7
Re: Nested vector initialization problem
Originally Posted by Paul McKenzie
That is an OS, not a compiler. You need to tell us the compiler and compiler version you're using.
Second, that line yields a compiler error, while your original post states a linker error.
That is not a linker error, that is a compiler error.
Regards,
Paul McKenzie
Thanks Paul for correcting me. I will put the exact compilation environment for clarification in the next post.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|