views:

119

answers:

3
+2  A: 

It looks like you're not compiling/linking tokenize.cpp.

It's probably not the code itself, but how you have it setup in Visual Studio.

Is it possible that VS isn't including tokenize.cpp in your application?

You can test that this is the problem by moving the functions from tokenize.cpp to main.cpp. If the errors go away, that's the problem.

Jon-Eric
+2  A: 

Not to do with the linker but in your header Tokenizer.h you say:

 #include "Tokenize.h"

what is Tokenize.h? You haven't shown it. also, your include guards seem to be guarding against this file.

anon
good catch - that was just a typo when posting
Wallter
@Walter so this isn't the real code? Don't ever, ever do that! Always post the real code using copy and paste.
anon
+2  A: 

There were several problems with your posted code. In order of discovery:

Tokenize::Tokenize(char const string [], char Delimiter) {
 current_ptr = string;
 delimiter = Delimiter;
};

You are trying to assign a const pointer to a non-const member variable. Can't do this; change the definition of the Tokenize ctor to:

Tokenize::Tokenize(char * const string , char Delimiter) {
 current_ptr = string;
 delimiter = Delimiter;
};

In Tokenize::next() change:

  while ((current_ptr)++ != ' ') {}

...to:

  while (*(current_ptr++) != ' ') {}

And just below that you have a bad escape sequence. Change:

  if ( *current_ptr == ' ' ) { *current_ptr = '/0'; (current_ptr)++; }

...to:

if ( *current_ptr == ' ' ) { *current_ptr = '\0'; (current_ptr)++; }

Once I fixed these errors, your code compiled fine. I didn't get the unresolved external error you were getting, so you must not be compiling tokenize.cpp

John Dibling