- #1
jck_ccc
- 5
- 0
Any help is greatly appreciated
I am trying to sort a string of vectors in the proper order. My problem does not involve theory, it involves syntax errors. Moving from Java to C++ is sure a pain..
I have 2 c++ files, sorting.h and sorting.cpp
I keep getting this error:
sorting.cpp(88) : error C3861: 'sortString': identifier not found
The code will sort a vector of type string via insertion sort.
Googled for the past hour, nothing
Looked at old notes, no help
Homework Statement
I am trying to sort a string of vectors in the proper order. My problem does not involve theory, it involves syntax errors. Moving from Java to C++ is sure a pain..
I have 2 c++ files, sorting.h and sorting.cpp
I keep getting this error:
sorting.cpp(88) : error C3861: 'sortString': identifier not found
Code:
//sorting.h
#pragma once
#include <string>
#include <vector>
using namespace std;
class sorting
{
public:
sorting(void);
~sorting(void);
vector<string> sortString(vector<string>);
bool compString(string, string);
};
Code:
//sorting.cpp
#include "sorting.h"
#include "stdlib.h"
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
sorting::sorting(void){}
sorting::~sorting(void){}
//implemented with insertion sort in mind
vector<string> sorting::sortString(vector<string> s){
int current = 1;
string temp;
int walker;
int size = s.size();
while (current < size){
temp = s[current];
walker = current -1;
while ((walker >= 0) && compString(temp,s[walker])){
s[walker+1] = s[walker];
walker = walker - 1;
}
s[walker+1] = temp;
current++;
}
return s;
}
//string comparator made easier
bool sorting::compString(string s1, string s2){
if (s1.compare(s2) == 1)
return true;
return false;
}
int main() {
vector<string> vec;
vec.push_back("asdf"); vec.push_back("abcd"); vec.push_back("zzzz");
vector<string> vec2 = sortString(vec); //errors out RIGHT HERE
/*for (int i = 0; i < vec2.size(); i++){
cout << vec2[i];
}*/
return 0;
}
Homework Equations
The code will sort a vector of type string via insertion sort.
The Attempt at a Solution
Googled for the past hour, nothing
Looked at old notes, no help