Topic: Problems with STL: (missing ';' before '<')
Author: jcoffin@taeus.com (Jerry Coffin)
Date: 1999/09/15 Raw View
In article <7rljid$6od$1@news1.sunrise.ch>, Ingo.Weissmann@saf-ag.com
says...
> Hi all,
>
> I tried to implement the vector and the string class from the STL
> in Visual Studio 6.0, but I always get the error message:
> " missing ';' before '<' "
>
> I looked for missing ';' but there wasn't a missing semicolon.
> Then I thought perhaps it is the string class, so I retyped
> vector<string> to vector<int> and tried it again...
> ...the same error.
>
> Here some sample code where the error occures:
>
> protected:
> BOOL m_bFileRead;
> BOOL m_bModuleRead;
> vector<string> m_vMKeys;
> vector<string> m_vMKeyDcr;
>
> So, what is the problem? Does anybody knows something
> about this error? How can I solve it?
According to the standard (trying to keep this at least close to
topical) vector and string are both in a namespace named std, and
there's a standard type named `bool', which you might as well use, so
the code above becomes:
protected:
bool m_bFileRead;
bool m_bModuleRead;
std::vector<std::string> mvMKeys;
std::vector<std::string> m_vMKeyDcr;
Of course C++ also has a tight enough type system that the 'b' and 'v'
prefixes (or infixes might be a more accurate term) aren't really
accomplishing anything useful either, so you might consider using more
readable and understandable names for your variables, but that gets to
be an entirely different question (not to mention being completely
unrelated to the standard).
--
Later,
Jerry.
The Universe is a figment of its own imagination.
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Ingo Weissmann" <Ingo.Weissmann@saf-ag.com>
Date: 1999/09/14 Raw View
Hi all,
I tried to implement the vector and the string class from the STL
in Visual Studio 6.0, but I always get the error message:
" missing ';' before '<' "
I looked for missing ';' but there wasn't a missing semicolon.
Then I thought perhaps it is the string class, so I retyped
vector<string> to vector<int> and tried it again...
...the same error.
Here some sample code where the error occures:
protected:
BOOL m_bFileRead;
BOOL m_bModuleRead;
vector<string> m_vMKeys;
vector<string> m_vMKeyDcr;
So, what is the problem? Does anybody knows something
about this error? How can I solve it?
Thanks for patience,
Ingo Weissmann
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Ron Natalie <ron@sensor.com>
Date: 1999/09/14 Raw View
It looks to me like the compiler has not seen a declaration of
vector (the error message is a bit misleading, I admit).
How did you introduce vector to this code?
Do you have
#include <vector.h>
or
#include <vector>
in your code? Also, if you used the latter you need
to use std::vector (or move vector into the global
namespace with a using directive).
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]