Convert a VC++program written in .cpp and .bat to a regular MC++ program
Hi...
Here are my comments on your code:
1- I'm not sure whether you intended to declare your
class inside main(), but if you did, move it outside.
2- Every class declaration needs an opening { and
closing }. The second one should have ; next to it.
3- Instead of Finalize, use destructor which looks like
this: ~Object(); A destructor is the class name preceeded
by ~.
4- Object is the name of the framework's class that every
other managed class derive from. So, choosing Object as
your class name is not a very good idea.
Finally, I copied your class to a cpp file in a console
project, put ; at the end and commented out Finalize and
it compiles perfectly. Of course to link that code you
need some definitions for your functions.
Ataa A. El-Ganayni
www.cppsoftware.ca
Quote:
>-----Original Message-----
>Hi all,
>When I tried to build the attached program that was
>written in .cpp and .bat by some expert and converted to
>a regular MC++ program by me (see below), I got 5 errors:
>ChallaChap03Sample03.cpp(14) : error C2143: syntax
>error : missing ';' before '<class-head>'
>ChallaChap03Sample03.cpp(25) : error C3840: declaration
>of 'void Object::Finalize(void)' not allowed; use
>destructors to implement finalization
>ChallaChap03Sample03.cpp(27) : error C2059: syntax
>error : 'return'
>ChallaChap03Sample03.cpp(27) : error C2238: unexpected
>token(s) preceding ';'
>ChallaChap03Sample03.cpp(29) : fatal error C1004:
>unexpected end of file found
>Build log was saved
>at "file://c:\C++Projects\ChallaChap03Sample03
>\Debug\BuildLog.htm"
>ChallaChap03Sample03 - 5 error(s), 0 warning(s)
>---------------------- Done ----------------------
> Build: 0 succeeded, 1 failed, 0 skipped
>//////////////////////////////////////////////
>// This is the main project file for VC++ application
>project
>// generated using an Application Wizard.
>#include "stdafx.h"
>#using <mscorlib.dll>
> #include <tchar.h>
> using namespace System;
>// This is the entry point for this application
> int _main(void)
> __gc class Object {
> public:
> Object();
> bool Equals(Object*);
> virtual int GetHashCode();
> System::Type* GetType();
> virtual System::String* ToString();
> static bool Equals(Object*, Object*);
> static bool ReferenceEquals(Object*, Object*);
> protected:
> void Finalize(); // C3840
> Object* MemberwiseClone();
> return 0;
> }
>//////////////////////////////////////
>Please help and tell me how to correct them.
>Thanks in advance,
>Scott Chang
>.