error that i cant quite understand,leave alone debug

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eternalLearner
    New Member
    • May 2007
    • 35

    error that i cant quite understand,leave alone debug

    i am using

    [code=cpp]
    vector< pair<string,dou ble> > v;

    string k = function_coded( v);

    where ,

    string function_coded( vector< pair<string,dou ble> > v )
    {
    //do something
    }
    [/code]

    but while complilling i get the following error,please help .

    error: conversion from ‘std::vector<st d::pair<std::ba sic_string<char , std::char_trait s<char>, std::allocator< char> >, double>, std::allocator< std::pair<std:: basic_string<ch ar, std::char_trait s<char>, std::allocator< char> >, double> > >’ to non-scalar type ‘std::vector<st d::basic_string <char, std::char_trait s<char>, std::allocator< char> >, std::allocator< std::basic_stri ng<char, std::char_trait s<char>, std::allocator< char> > > >’ requested
  • hsn
    New Member
    • Sep 2007
    • 237

    #2
    i never used vector <pair ....>
    does that even work...???????? ??????????????? ?

    tell me

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      hsn vector< pair< ... > > should be fine.

      eternalLearner, the code you have posted compiles fine for me without errors (VS 2005). I suggest that either you have not posted what is actually in your code or you have posted the wrong piece.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Originally posted by hsn
        i never used vector <pair ....>
        does that even work...???????? ??????????????? ?
        Yes it does. The pair<> is an STL cointainer that has two public data members named first and second. Pair objects are used by other containers, like map, where the key is first and the value for the key is second.

        Comment

        • eternalLearner
          New Member
          • May 2007
          • 35

          #5
          Originally posted by hsn
          i never used vector <pair ....>
          does that even work...???????? ??????????????? ?

          tell me
          ya that does work . :)

          Comment

          • eternalLearner
            New Member
            • May 2007
            • 35

            #6
            Originally posted by Banfa
            hsn vector< pair< ... > > should be fine.

            eternalLearner, the code you have posted compiles fine for me without errors (VS 2005). I suggest that either you have not posted what is actually in your code or you have posted the wrong piece.
            Hmm,i did not post the incorrect code,but the peoblem got solved wen i declared the function_coded( vect...) in the header file as extern,though i dont quite understand why it was so .

            Thanks you to all. :)

            Comment

            Working...