Convert a VC++program written in .cpp and .bat to a regular MC++ program 
Author Message
 Convert a VC++program written in .cpp and .bat to a regular MC++ program

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



Wed, 02 Nov 2005 22:37:31 GMT  
 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

>.



Thu, 03 Nov 2005 03:57:58 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Need Help in converting Simple C program to VC

2. How can i write database program with VC?

3. Socket Programming (How to program a timeout mechanism on a read/write call)

4. Program written in C slows other DOS programs when running on Pentium II or III

5. Writing a program that can communicate with other programs on the Internet

6. PROGRAMMING SOFTWARE (WRITING SOFTWARE PROGRAMS(FOR ANY TASTE))

7. executing a DOS BAT from within C/C++ program

8. hiding cmd prompt while exec a BAT file my program

9. Converting VB program to MFC based program

10. Executing .bat file from VC 1.52 AND VC 4.2

11. Convert C++ Program (.cpp file,.h file & programming codes) to Visual C++.NET

12. How do I include OpenGL in MC++ program

 

 
Powered by phpBB® Forum Software