F
Felix85
Here is the error i am getting:
/tmp/ccu9LP0x.o: In function
`command::tokenizer(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >)':
command.cpp.gnu.linkonce.t._ZN7command9tokenizerESsSt6vectorISsSaISsEESs+0x59):
undefined reference to `command::com'
command.cpp.gnu.linkonce.t._ZN7command9tokenizerESsSt6vectorISsSaISsEESs+0xe9):
undefined reference to `command::com'
collect2: ld returned 1 exit status
Here is the source code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class command {
public:
static void tokenizer(string str, vector<string> words, string
delimiter){
string::size_type pos1 = 0;
string::size_type pos2 = str.find_first_of(delimiter);
com.push_back(str.substr(pos1 ,pos2 - 1));
pos1 = pos2 + 1;
while(pos2 != string::npos){
pos2 = str.find_first_of(delimiter, pos2);
com.push_back(str.substr(pos1 ,pos2 - 1));
pos1 = pos2 + 1;
}
}
static void getCommand(string c){
tokenizer(c, com, " ");
if(com.size() == 1){
} else if(com.size() == 2){
} else { }
}
private:
static vector<string> com;
};
int main()
{
vector<string> test;
string t = "hello how are you doing today";
command::tokenizer(t, test, " ");
cout << "there are " << test.size() << " words in that string.\n";
int i;
for(i = 0; i < test.size(); i++){
cout << test;
}
return 0;
}
Thanks in advance.
/tmp/ccu9LP0x.o: In function
`command::tokenizer(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::vector<std::basic_string<char,
std::char_traits<char>, std::allocator<char> >,
std::allocator<std::basic_string<char, std::char_traits<char>,
std::allocator<char> > > >, std::basic_string<char,
std::char_traits<char>, std::allocator<char> >)':
command.cpp.gnu.linkonce.t._ZN7command9tokenizerESsSt6vectorISsSaISsEESs+0x59):
undefined reference to `command::com'
command.cpp.gnu.linkonce.t._ZN7command9tokenizerESsSt6vectorISsSaISsEESs+0xe9):
undefined reference to `command::com'
collect2: ld returned 1 exit status
Here is the source code:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class command {
public:
static void tokenizer(string str, vector<string> words, string
delimiter){
string::size_type pos1 = 0;
string::size_type pos2 = str.find_first_of(delimiter);
com.push_back(str.substr(pos1 ,pos2 - 1));
pos1 = pos2 + 1;
while(pos2 != string::npos){
pos2 = str.find_first_of(delimiter, pos2);
com.push_back(str.substr(pos1 ,pos2 - 1));
pos1 = pos2 + 1;
}
}
static void getCommand(string c){
tokenizer(c, com, " ");
if(com.size() == 1){
} else if(com.size() == 2){
} else { }
}
private:
static vector<string> com;
};
int main()
{
vector<string> test;
string t = "hello how are you doing today";
command::tokenizer(t, test, " ");
cout << "there are " << test.size() << " words in that string.\n";
int i;
for(i = 0; i < test.size(); i++){
cout << test;
}
return 0;
}
Thanks in advance.