So I am trying to write this small program using a void method from a source file but it does not work..It is giving me some weird error, that I can't comprehend. My code SEEMS correct but maybe you real programmers out there can help me point out my mistake, as the error is
Code:
main.obj : error LNK2019: unresolved external symbol "void __cdecl ordered(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::list<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > >)" (?ordered@@YAXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$list@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V?$allocator@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@@2@@Z) referenced in function _main
Here are my 3 files
Code:
#include <iostream>
#include <list>
#include <string>
#include "oLine.h"
#include <vector>
using std::cout;
using std::endl;
using std::string;
using std::cin;
using std::list;
int main(){
//asks for user input
cout << "Please type in your input: ";
//the container
list<string> sentence;
string x;
//adds user input to container
while(cin >> x){
sentence.push_back(x);
}
//sorts out sentence
list<string> sorted = sentence;
sorted.sort();
//starts container from beginning, and continues until the end
for(list<string>::iterator iter = sorted.begin(); iter != sorted.end(); iter++){
ordered(*iter, sentence);
}
return 0;
}
Code:
#ifndef GUARD_oLine_h
#define GUARD_oline_h
//oline.h
#include <string>
#include <list>
void ordered(std::string, std::list<std::string>);
#endif
Code:
#include "oLine.h"
#include <string>
#include <iostream>
#include <list>
using std::string;
using std::cout;
using std::list;
void ordered(string& start, list<string>& phrase){
//counts the number of words outputted
list<string>::iterator count = phrase.begin();
//current word the iterator is on
list<string>::iterator current = phrase.begin();
//while the count is not the end
while(count != phrase.end()){
//if start equals current and current isnt the end
//we output current and increment current along with the count
if(start == *current && current != phrase.end()){
cout << *current << ' ';
current++;
count++;
}
//since it is the end, we output current and set it back to the beginning
else if(start == *current && current == phrase.end()){
cout << *current << ' ';
current = phrase.begin();
count++;
}
//otherwise just increment current
else{
current++;
}
}
}
Thanks for your help!