Post by Mike CopelandPost by Thomas J. GritzanPost by Mike CopelandHere's a complete program that demonstrates the problem, as well as
all error diagnostics. TIA
#include <iostream>
#include <string>
using namespace std;
struct dbeBuild
{
int bibNumber;
char source;
string body;
} dbeWork;
dbeBuild *dbeZeroBibs = NULL;
dbeZeroBibs = new dbeBuild[2505]; // the errors are on this line
This is outside of any function. The above is a statement that has to be
inside of a function body.
Post by Mike Copeland// error C2501: 'dbeZeroBibs' : missing storage-class or type specifiers
// error C2040: 'dbeZeroBibs' : 'int' differs in levels of indirection
from 'struct dbeBuild *'
[...]
Of course! How stupid of me. Sorry for the bother (but thanks!)...
However, it _does_ go to prove my point that Microsoft's diagnostics
are often incomprehensible. <sigh...> 8<{{
The diagnostic messages cannot possibly include all education materials
for the language you're using. Statements outside of functions are
*expected* to be declarations. A declaration without an explicit type
is assumed to be of 'int' type (thank C inventors for that and the
spirit of "backward compatibility"). Initialization of an 'int' with a
pointer produces your "different levels of indirection" message.
BTW, VC 2010 gives this diagnostic:
test.cpp(12): error C4430: missing type specifier - int assumed.
Note: C++ does not support default-int
test.cpp(12): error C2040: 'dbeZeroBibs' : 'int' differs in levels of
indirection from 'dbeBuild *'
test.cpp(12): error C2440: 'initializing' : cannot convert from
'dbeBuild *' to 'int'
Of course, it might be more helpful if it immediately flagged the
erroneous line as a *redeclaration/redefinition* of the variable, but I
guess MSVC developers have better things to do than to look for all
possible causes of the compiler's inability to compile a declaration.
There is logical explanation for everything, and there are going to be
people who aren't satisfied with anything you give them. It's a well
known phenomenon that one can't satisfy *everybody*. So, the principle
often adhered to is 'sapienti sat'.
Get yourself an Express version of Visual Studio 2010, it's *free*. At
least you're going to have a modern compiler. And a decent book on C++,
while you're at it. Being "quite old" is no excuse for staying behind
as far as technology is concerned. And, following a common idiom, you
have to realize that you _can't afford *not* to upgrade_ to a new
version. As for its being "daunting", I'll give you the very old
Russian saying: "Eyes are afraid but hands are doing".
Good luck!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask