Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Dev C++ cant accept vector??

Dev C++ cant accept vector??

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicshelpquestion
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nuttynibbles
    wrote on last edited by
    #1

    Hi, im using vector strvector. it works in unix but when i run in Dev c++, it prompt me error like no matching function for call tp `Vector`.....etcc why is this so??

    R 1 Reply Last reply
    0
    • N nuttynibbles

      Hi, im using vector strvector. it works in unix but when i run in Dev c++, it prompt me error like no matching function for call tp `Vector`.....etcc why is this so??

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      1. Show your code. 2. Show the exact error message that the compiler issued.

      “Follow your bliss.” – Joseph Campbell

      N 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        1. Show your code. 2. Show the exact error message that the compiler issued.

        “Follow your bliss.” – Joseph Campbell

        N Offline
        N Offline
        nuttynibbles
        wrote on last edited by
        #3

        #include <vector>
        using namespace std;

        vector<string> vectorstr ;

        ....

        vectorstr.push_back("....")

        ...

        for(int i=0;i<this->vectorstr.size(); i++){
        cout << "test:" << this->vectorstr.at(i) << endl;
        }

        ...

        void removeduplicates(vector<string>& vec){
        sort(vec.begin(), vec.end());
        vec.erase(unique(vec.begin(), vec.end()), vec.end());
        }

        i have been getting error like: implicit declaration of function int sort implicit declaration of function int unique no matching function for call to vectormodified on Sunday, November 29, 2009 12:55 PM

        R 1 Reply Last reply
        0
        • N nuttynibbles

          #include <vector>
          using namespace std;

          vector<string> vectorstr ;

          ....

          vectorstr.push_back("....")

          ...

          for(int i=0;i<this->vectorstr.size(); i++){
          cout << "test:" << this->vectorstr.at(i) << endl;
          }

          ...

          void removeduplicates(vector<string>& vec){
          sort(vec.begin(), vec.end());
          vec.erase(unique(vec.begin(), vec.end()), vec.end());
          }

          i have been getting error like: implicit declaration of function int sort implicit declaration of function int unique no matching function for call to vectormodified on Sunday, November 29, 2009 12:55 PM

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          nuttynibbles wrote:

          #include

          That doesn't help, does that? Which headers are you including? I suspect that you're missing something. Most probably #include <string> Uncheck the "Encode HTML tags when pasting", paste your code into the window, and ensure your code snippet is within a pre block (selecting the "Code Block" option, which you've already done).

          “Follow your bliss.” – Joseph Campbell

          N 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            nuttynibbles wrote:

            #include

            That doesn't help, does that? Which headers are you including? I suspect that you're missing something. Most probably #include <string> Uncheck the "Encode HTML tags when pasting", paste your code into the window, and ensure your code snippet is within a pre block (selecting the "Code Block" option, which you've already done).

            “Follow your bliss.” – Joseph Campbell

            N Offline
            N Offline
            nuttynibbles
            wrote on last edited by
            #5

            i have these headers

            #include <iostream>
            #include <sstream>
            #include <fstream>
            #include <stdio.h>
            #include <stdlib.h>
            #include <string.h>
            #include <time.h>
            #include <ctype.h>
            #include <map>
            #include <vector>
            using namespace std;

            S R 2 Replies Last reply
            0
            • N nuttynibbles

              i have these headers

              #include <iostream>
              #include <sstream>
              #include <fstream>
              #include <stdio.h>
              #include <stdlib.h>
              #include <string.h>
              #include <time.h>
              #include <ctype.h>
              #include <map>
              #include <vector>
              using namespace std;

              S Offline
              S Offline
              Sarath C
              wrote on last edited by
              #6

              I think you should #include<algorithm> to use sort.

              -Sarath.

              My blog - Sharing My Thoughts

              Rate the answers and close your posts if it's answered

              N 1 Reply Last reply
              0
              • S Sarath C

                I think you should #include<algorithm> to use sort.

                -Sarath.

                My blog - Sharing My Thoughts

                Rate the answers and close your posts if it's answered

                N Offline
                N Offline
                nuttynibbles
                wrote on last edited by
                #7

                Hi sarath, tks. i included #include <algorithm> and the error message on sort is no more. however, the error on "no matching function for call to `vector...." is still there. im pretty sure i use the vector correctly. the error is at the line: cout << this->vector.at(i) << endl;

                C CPalliniC S 3 Replies Last reply
                0
                • N nuttynibbles

                  Hi sarath, tks. i included #include <algorithm> and the error message on sort is no more. however, the error on "no matching function for call to `vector...." is still there. im pretty sure i use the vector correctly. the error is at the line: cout << this->vector.at(i) << endl;

                  C Offline
                  C Offline
                  Cedric Moonen
                  wrote on last edited by
                  #8

                  Could you please post the full and exact error message ?

                  Cédric Moonen Software developer
                  Charting control [v2.0] OpenGL game tutorial in C++

                  1 Reply Last reply
                  0
                  • N nuttynibbles

                    Hi sarath, tks. i included #include <algorithm> and the error message on sort is no more. however, the error on "no matching function for call to `vector...." is still there. im pretty sure i use the vector correctly. the error is at the line: cout << this->vector.at(i) << endl;

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #9

                    The following piece of code (basically yours...) runs fine on my system (WinXP, Visual Studio 2005):

                    #include <string>
                    #include <vector>
                    #include <iostream>
                    using namespace std;
                    void main()
                    {

                    vector<string> vectorstr;
                    vectorstr.push_back("....");

                    for(int i=0;i<vectorstr.size(); i++)
                    {
                    cout << "test:" << vectorstr.at(i) << endl;
                    }

                    }

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • N nuttynibbles

                      Hi sarath, tks. i included #include <algorithm> and the error message on sort is no more. however, the error on "no matching function for call to `vector...." is still there. im pretty sure i use the vector correctly. the error is at the line: cout << this->vector.at(i) << endl;

                      S Offline
                      S Offline
                      Sarath C
                      wrote on last edited by
                      #10

                      I think the char* is not automatically deduced from the string class. Please try the following code. cout << this->vector.at(i).c_str() << endl;

                      -Sarath.

                      My blog - Sharing My Thoughts

                      Rate the answers and close your posts if it's answered

                      1 Reply Last reply
                      0
                      • N nuttynibbles

                        i have these headers

                        #include <iostream>
                        #include <sstream>
                        #include <fstream>
                        #include <stdio.h>
                        #include <stdlib.h>
                        #include <string.h>
                        #include <time.h>
                        #include <ctype.h>
                        #include <map>
                        #include <vector>
                        using namespace std;

                        R Offline
                        R Offline
                        Rajesh R Subramanian
                        wrote on last edited by
                        #11

                        You keep giving showing your code in bits and pieces. It's very difficult to help you. However, it appears that you're trying to sort a vector such that there are only unique elements. See if this helps:

                        // Cons.cpp : Defines the entry point for the console application.

                        #include "stdafx.h"
                        #include <iostream>
                        #include <vector>
                        #include <string>
                        #include <algorithm>

                        using namespace std;

                        void UniqueSort(std::vector& MyVec)
                        {
                        sort(MyVec.begin(), MyVec.end());
                        MyVec.erase(unique(MyVec.begin(), MyVec.end()), MyVec.end());
                        }

                        int _tmain()
                        {
                        vector vec;
                        vec.push_back("one");
                        vec.push_back("two");
                        vec.push_back("one"); //duplicate
                        vec.push_back("four");
                        vec.push_back("five");
                        vec.push_back("six");
                        vec.push_back("seven");
                        vec.push_back("eight");
                        vec.push_back("six"); //duplicate

                        //cout<<"Before sorting"< 
                        

                        “Follow your bliss.” – Joseph Campbell

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups