errors

Hey, I'm new to programming, and I bought Visual C++.net 2003
and the "step by step" book for it. I followed the process in
chapter one and compiled the 'Hello, world' hehe, which is kinda
lame, but anyway the _gc class is chapter two, and I've written
the text exactly how it is in the book, but I get three error
messages. The first and second are for this line:

_gc class Animal

...and the errors say: error C2143:syntax error:missing';'before<class-head>
error C2501:'_gc':missing storage-class or type
specifiers

the third is for this line:

String *strName;

...and the error says: error C3265:cannot declare a managed 'strName' in an
unmanaged animal

I know this is probably too simple to fix, but this is very new to me, any
feedback would help.
_gc? I've never heard of that before.

Please post the rest of your code (don't forget the code tags!)-- Being able to compile the thing on my own computer always makes debugging easier.
Greetings,
__gc is old syntax for managed extensions for C++, i think version 1.
The new syntax is now ref, like:
1
2
3
ref class Animal{
//aninal stuff goes here.
};


It's been awhile since i saw that, even though the new compilers(just to support old code) supports it its not used anymore.

I recommend updating your IDE AND your book;

Also it is two underlines(_) characters not 1
1
2
3
__gc class Animal{
//animal stuff goes here
};


By managed extensions i mean .NET C++/CLI.

Jeff
Last edited on
Thanks Jeff, it was that I only had one '_' when I needed two. It works
now perfectly. I haven't tried 'ref' yet but I will, and I'll definitely get a
newer version of the book (After I check to see that it is updated).
I'm not sure if I've updated my IDE but I did download and install the
latest updates off of Microsofts website when I installed the program.
Thanks again, it's a big help, I'm really excited about learning this.

Grohg
hey Grohg, once you get an up to date book try the newer versions of Visual studio, like 2005 or 2008.

http://msdn2.microsoft.com/en-us/downloads/default.aspx

But yeah you can still use that book for studying and track the .NET changes using the msdn site:
www.msdn.com

cheers

Jeff
Last edited on
Topic archived. No new replies allowed.