Dev C++ cant accept vector??
-
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??
1. Show your code. 2. Show the exact error message that the compiler issued.
“Follow your bliss.” – Joseph Campbell
-
1. Show your code. 2. Show the exact error message that the compiler issued.
“Follow your bliss.” – Joseph Campbell
#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
-
#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
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
-
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
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; -
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;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
-
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
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;
-
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;
Could you please post the full and exact error message ?
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++ -
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;
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] -
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;
-
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;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