CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2008
    Posts
    15

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,765

    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.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

  3. #3
    Join Date
    Jun 2008
    Posts
    15

    Re: Nested vector initialization problem

    Quote Originally Posted by laserlight View Post
    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;
    }

  4. #4
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,721

    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()));

  5. #5
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Nested vector initialization problem

    Quote Originally Posted by Ericxx View Post
    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.

  6. #6
    Join Date
    Jun 2008
    Posts
    15

    Re: Nested vector initialization problem

    Thanks Philip. The problem has already been solved.

  7. #7
    Join Date
    Jun 2008
    Posts
    15

    Re: Nested vector initialization problem

    Quote Originally Posted by Paul McKenzie View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured