error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'
#ifndef _lexicon_h
#define _lexicon_h
class Lexicon {
public:
/* Constructor: Lexicon */
/* Constructor initializes a new lexicon to represent empty word list. */
Lexicon();
/* Destructor: ~Lexicon */
/* The destructor frees any storage associated with the lexicon. */
~Lexicon();
/* Member function: getWordIterator */
/* This member function returns an iterator over all words contained */
/* in the lexicon in alphabetical order. */
Iterator<string> getWordIterator();
};
#endif
In a header file, I'd refrain from using the usingnamespace std; simply because you may run into issue later on. If you plan on keeping this is a local code and you've already used the using namespace call, then yes, string would be fine.
Just trying to show you properly rather than poor techniques.
Then, something you omitted is the cause. Paste the Iterator implementation (without omitting anything) here. If it's a big file, use http://www.pastebin.org/
I believe they meant they omitted the header files to reduce the size of the paste. If Iterator was defined elsewhere, then you need to know how, and how it can be used.
My response was in regards as to what was shown and since they accepted the answer, I assumed it was what they were looking for.
Iterator could have been misspelled and they could have been confused on the implementation of it.
#include "stdafx.h"
#include <cstdlib> //added http://forums.devx.com/showthread.php?t=152439
#include <string>
#include <iostream>
#include <fstream>
#include <set>
#include "genlib.h" //www.keithschwarz.com/cs106l/winter20072008/handouts/020_Writing_Without_Genlib.pdf
#include "simpio.h"
#include "lexicon.h"
#include "iterator.h"
#include "set.h" //added to match lexicon.h and main.cpp file 6/8/2012 - seemed to correct most (dozens) of errors
usingnamespace std;
Iterator<string> Lexicon::getWordIterator()
{
Iterator<string> *iter = new Iterator<string>();
allWordsHelper(root, "", iter);
return *iter;
}
C2556: 'Iterator<ElemType> Lexicon::getWordIterator(void)' : overloaded function differs only by return type from 'std::_String_iterator<_Elem,_Traits,_Alloc> Lexicon::getWordIterator(void)'
error C2371: 'Lexicon::getWordIterator' : redefinition; different basic types
I did not post the entire code, just the header and the function the compiler found the error in
I am going to revert the edit and try another path to a solution. The Iterator<string> getWordIterator(); compiled in a previous working version so i know it works. And, the edit created the template mismatch errors. I ma going to focus on the Linker errors and check the source files.