Re: typedef Syntax Error
On Oct 31, 10:16 pm, Victor Bazarov <v.Abaza...@comAcast.net>
wrote:
red floyd wrote:
On Oct 31, 2:01 pm, mrc2...@cox.net (Mike Copeland) wrote:
I'm getting a syntax error on the "typedef" code line here.
Any thoughts on why? TIA
struct CSTYPE
{ =
// City/State Record
// City/State "Key"
// City
// State Code};
typedef map<string, CSTYPE> CSINFO; // <=== error here
extern CSINFO cityStInfo;
extern map<string, CSTYPE>::iterator csIter;
extern CSTYPE workCS;
1. did you #include <map> and <string>?
2. map and string live in the std:: namespace
3. Would you care to describe the specific error?
It's possible that his compiler does not allow the use of
incomplete types as template arguments, even in typedefs, and
'CSTYPE' is incomplete at that point...
That wasn't the case in his original code. If you'll look at
the end of the line "string csState;", you'll see the closing
brace of CSTYPE. For some reasons, something in the news very
often seems to move a line with just a }: to the end of the
preceding line. (I've always suspected Google, because that's
what I use to read news, and I'm constantly seeing this.)
Without the closing brace, of course, the code would be illegal.
Because of the incomplete type, but also because you're not
allowed to use extern in a class either (and that error requires
a dignostic).
Like Mike, I rather suspect that he's either forgotten the
include, and he's clearly fogotten the std::. Which means that
string and map are unknown symbols. To reasonably parse C++,
the compiler needs to know when a symbol names a type; use an
unknown symbol where a type is required, the compiler will
generally suppose it isn't a type (which results in a syntax
error), and the quality of the error messages go downhill from
there.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34